case when then else end mysql
select (@rownum:=@rownum+1) AS serial_Num, tb_ser.name as server_Name, count(tb_uer.id) as regist_Num ,
count(case when tb_uer.status=0 then tb_uer.id else null end) as no_Active,
count(case when date_format(tb_uer.lastLoginTime,‘%Y-%m-%d‘)= @con1 then tb_uer.id else null end) as active_Num,
count(tb_uer.id)-count(case when date_format(tb_uer.lastLoginTime,‘%Y-%m-%d‘)=@con1 then tb_uer.id else null end) as no_Active_Num
from p_service_branch tb_ser left join
p_cuser tb_uer on tb_uer.serviceId=tb_ser.id
,(SELECT @rownum:=0) rownumber where 1=1 @con2 @con3 group by tb_ser.id
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。