关于SQL语句写法,在SQL SERVER 2005中使用

2024-11-23 09:11:10
推荐回答(1个)
回答1:

select
sum(case when a.number>5 then 1 else 0 end) as count_1,
sum(case when a.number>5 then a.number else 0 end) as sum_1 ,
sum(case when a.number<5 then 1 else 0 end) as count_2,
sum(case when a.number<5 then a.number else 0 end) as sum_2
from (select number from table_1 where date>‘2013-01-01 ’and date<=‘2013-01-31’) a
希望能帮助到你!