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

2024年11月23日 09:11
有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
希望能帮助到你!