wdjh.net
当前位置:首页 >> sqlsErvEr Count CAsE >>

sqlsErvEr Count CAsE

CASE WHEN price

select sum(case when A.CLOSE_ID='T' then 1 else 0 end) from (select distinct A.CLOSE_ID,A.MO_NO from A) T '完成种数'=COUNT(CASE WHEN A.CLOSE_ID='T' THEN A.MO_NO ELSE 0 END)这句的逻辑就有问题,你要求A.CLOSE_ID='T' 时, A.MO_NO ...

Select A, count(B) as total, sum(case when B > 30 then 1 else 0 end) as total1, sum(case when B > 20 then 1 else 0 end) as total2 from ABC group by A

select sum(case when(C=2) then 1 else 0 end) count_C,sum(case when(D=2) then 1 else 0 end) count_D from 表 where A='a' and B='c' 这样得到的count_C和count_D就是统计出来的C和D列的值。

sum(case when 条件 then 1 else 0 end) 你说的是这种的吧 ,如果统计条数的话就要用sum ,用count无论是1还是0都是都会统计进去

select SUM( CASE WHEN a.score>=60 THEN 1 ELSE 0 END ) pass, SUM( CASE WHEN a.end

没有看到整个存储过程的语句,当就这一条语句看不出什么东西。

select count(case when status='success' then 1 else 0 end),count(case when status='failed' then 1 else 0 end) ,convert(char,created,112) from biao group by convert(char,created,112)

遇到 XXX情况 就 XXX 遇不到就 XXX 结束 case when …… then …… else …… end

select 班级编号,case con when isnull(con,0)>0 then '该班级有党员' end as 是否有党员 from ( select 班级编号,count (*) as con from 学生基本信息表 where 班级编号=20041001 and 政治面貌='党员' group by 班级编号,政治面貌) taba

网站首页 | 网站地图
All rights reserved Powered by www.wdjh.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com