现在查到一个count集合:
select count(oper_type) 合计
from man_operlog m
group by m.oper_type但是怎样是想怎样的效果?登录次数 客户数(为上面的count)
20次以上 0
15-19次 0
10-14次 0
5-9次 5
1-4次 0
0次 0
select count(oper_type) 合计
from man_operlog m
group by m.oper_type但是怎样是想怎样的效果?登录次数 客户数(为上面的count)
20次以上 0
15-19次 0
10-14次 0
5-9次 5
1-4次 0
0次 0
select '20次以上', count(oper_type) 合计
from man_operlog m
group by m.oper_type
having count(oper_type) >20
union
select '15-19次', count(oper_type) 合计
from man_operlog m
group by m.oper_type
having count(oper_type) >=15 and count(oper_type) <=19
select case when 合计=0 then '0次'
when 合计 between 1 and 4 then '1-4次'
when 合计 between 5 and 9 then '5-9次'
when 合计 between 10 and 14 then '10-14次'
when 合计 between 15 and 19 then '15-19次'
when 合计 >=20 then '20次以上'
else null end 登录次数,
count(1) 客户数
from(
select m.oper_type,count(1) 合计
from man_operlog m
group by m.oper_type
)
select case when 合计=0 then '0次'
when 合计 between 1 and 4 then '1-4次'
when 合计 between 5 and 9 then '5-9次'
when 合计 between 10 and 14 then '10-14次'
when 合计 between 15 and 19 then '15-19次'
when 合计 >=20 then '20次以上'
else null end 登录次数,
count(1) 客户数
from(
select m.oper_type,count(1) 合计
from man_operlog m
group by m.oper_type
)
group by
case when 合计=0 then '0次'
when 合计 between 1 and 4 then '1-4次'
when 合计 between 5 and 9 then '5-9次'
when 合计 between 10 and 14 then '10-14次'
when 合计 between 15 and 19 then '15-19次'
when 合计 >=20 then '20次以上'
else null end
是否有个全量客户表,没有登录的客户,也要显示出来?如果不考虑上面这情况,那只要取登录日志表就行了。 否则,还需要 left join 一下 客户表。