jcgj.net
当前位置:首页 >> mysql CAsE whEn sum >>

mysql CAsE whEn sum

可以的,group by后边整个条件 就是列: CASE country WHEN'中国' THEN'亚洲' WHEN'印度' THEN'亚洲' WHEN'日本' THEN'亚洲' WHEN'美国' THEN'北美洲' WHEN'加拿大' THEN'北美洲' WHEN'墨西哥' THEN'北美洲' ELSE'其他'END

(1)数字 如果 Measures.CurrentMember 是空单元,则下面的示例返回 0,否则返回 1 IIf(IsEmpty(Measures.CurrentMember), 0, 1) (2)字符串 如果Measures.CurrentMember 是空单元,则下面的字符串返回字符串"Yes",否则返回字符串"No" IIf(IsEmpt...

试试这个,没有测试: select date, sum(if(a = 1, 1, 0)) as A1, sum(if(a = 2, 1, 0)) as A2from tab where a=1group by date

试试这个,没有测试: select date, sum(if(a = 1, 1, 0)) as A1, sum(if(a = 2, 1, 0)) as A2from tab where a=1group by date

可以的吧,出NULL是不是因为你字段的内容就是NULL埃 这里是一个测试,可以看到使用列名value来做then的值是可以的: mysql> select * from aaa;+------+-------+| id | value |+------+-------+| 1 | 1 || 2 | 3 || 3 | 4 || 4 | 4 || 5 | 4 || ...

可以用OR连接所有结果相同的条件呀,如: case when abs(sum(a.ycyl)+sum(a.ycsl)-sum(b.ycyl)-sum(b.ycsl))12 then '上升' else '下降' end xm 把其他的条件加进来就可以了

select case when vipStartDate is null then '9999999999' else vipStartDate end as vipStartDate from 表

select ifnull(colname,0) from tablename

Select name, sum(case when month=10 then money else 0 end) month10, sum(case when month=11 then money else 0 end) month11from tgroup by nameorder by name

mysql不太熟,不过你的要求就是简单嵌套就行了吧。 select @sum_rece:=s1+s2+s3+s4...+s10 from ( select (case when rece_day1 is null then rece_amt1 else 0) s1, (case when rece_day2 is null then rece_amt2 else 0) s2, 。。。。 from ...

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