我在一个表中有多个列,但我只希望在sql中选择这些列中的最高值。
示例信息:
D1 D2 D3 D4
----- ----- ----- -----
3 2 150 5
1 3 20 10输出需要是:
MaxPower
150
20
有谁知道做这件事的好方法吗?最好使用单个sql,但也可以使用vba。
发布于 2011-06-03 05:11:55
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发布于 2011-06-03 05:07:43
select max(max(d1,d2), max(d3,d4)) from table怎么样?
https://stackoverflow.com/questions/6220309
复制相似问题