美文网首页
sql判断-case when 2019-06-24

sql判断-case when 2019-06-24

作者: stayhungryQiu | 来源:发表于2019-06-25 18:48 被阅读0次

select  <想展示的东西1,想展示的东西2,...>

from <表>

group by <分组条件>

order by <排序条件>

desc/asc

-----------------------------------------------

想展示的东西:

1、直接源于某表 : t.<t表内字段名>

2、新加列:  <t表内字段处理(case when 判断))> as <想展示成的字段名>

                      ‘<想展示成的字段名> ’= <t表内字段处理case when 判断>

----------------------------------------------

t表内字段处理:

1、条件判断:

case

when t.<t表内字段名>='判断条件1' then  <判断条件1结果值>

when t.<t表内字段名>='判断条件2' then <判断条件2结果值>

else <非判断条件1\2结果值>

end

as <想展示成的字段名>

*注:case when 用来select创建字段,case when 也可以与group by , order by 使用。

博客园:https://www.cnblogs.com/zxtceq/p/5580983.html

相关文章

网友评论

      本文标题:sql判断-case when 2019-06-24

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