SQL语句when then else用法

2019-10-19  本文已影响0人  山猪cn
select case role when 'MENTOR' then 'USTAR' when 'STUDENT' then 'STUDENT' else role end as role,
sum(case when created_date >= '2019-08-14 00:00:00' and created_date <= '2019-08-21 00:00:00' then 1 else 0 end) as added,count(2) as total
from user
group by role;

通过html格式转换,结果如下

结果
上一篇下一篇

猜你喜欢

热点阅读