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
20
Anyone know a good way to do this? A single sql would be preferred but vba would work also.
How about select max(max(d1,d2), max(d3,d4)) from table
?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.