SQL语句求一个表中两列数据中的最大/最小值/标准差

表TABLE1 中 有两列数据 COL1和COL2,求这两列数据的最大值/最小值/标准差的SQL语句怎么写啊,求大神指点;
本人用的是ACCESS数据库,满意追分。



select case( 
when MAX(col1) > MAX(col2) then 'col1大'
when MAX(col1) < MAX(col2) then 'col2大'
else '相等' end)as COL1,
case( 
when MIN(col1) < MIN(col2) then 'col1小'
when MIN(col1) > MIN(col2) then 'col2小'
else '相等' end)as COL2,
case( 
when avg(col1) < avg(col2) then 'col1品均小与col2'
when avg(col1) > avg(col2) then 'col2品均小与col1'
else '相等' end)as COL3 
from table1

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-01-06
select MAX(col1) AS col1最大, MIN(COL1) AS COL1最小, MAX(col2) AS COL2最大, MIN(COL2) AS COL2最小, AVG(Col1) col1平均, AVG(col2) col2平均
from table1

追问

函数我知道,我的意思是怎么查询两列数据中的最大值。。。。语句要如何写,谢谢大神=。=

第2个回答  2014-01-07
select max(col1), min(col1), stdev(col1), max(col2), min(col2), stdev(col2)
from table1
相似回答