How to assign the max value across mulptiple fields to a single column in a select statement using MS-Access-2010 SQL?
I have multiple columns in a table but I only want the highest value from the columns to be selected in a sql.
Example Info:
D1 D2 D3 D4
----- ----- ----- -----
3 2 150 5
1 3 20 10
Output needs to be:
MaxPower
150 20Anyone know a good way to do this? A single sql would be preferred but vba would work 开发者_如何学Goalso.
select max(v) as maggiore from (
select id,d1 as v from table
union all
select id,d2 from table
union all
select id,d3 from table
union all
select id,d4 from table
) as t
group by id
How about select max(max(d1,d2), max(d3,d4)) from table
?
精彩评论