select sum(a.a) '0-10',sum(a.b) '10-20',sum(a.c) '20-30',sum(a.d) '30以上'
from
(select case when price>0 and price<=10 then 1 end as a,
case when price>10 and price<=20 then 1 end as b,
case when price>20 and price<=30 then 1 end as c,
case when price>30 then 1 end as d
from titles) as a
这是我用 CASE when 条件判断。老师说虽然说结果对,但是这个写着太复杂了,当遇到1000条。 是那我就要写几百 几千条CASE when 加以判断, 所以小弟在这求根据问题标题的要求写出结果一样的,比较简洁的语句,注意是聚合查询。
素胚勾勒不出你
有只小跳蛙
蛊毒传说
猛跑小猪
慕哥6287543
心有法竹
相关分类