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

2025-04-07 19:36:40
推荐回答(1个)
回答1:



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