美文网首页
SQL语句when then else用法

SQL语句when then else用法

作者: 山猪cn | 来源:发表于2019-10-19 04:13 被阅读0次
    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格式转换,结果如下

    结果

    相关文章

      网友评论

          本文标题:SQL语句when then else用法

          本文链接:https://www.haomeiwen.com/subject/aqlgmctx.html