使用case更改查询结果
两种查询方式
具体数值查询(case后为列名)
#具体数值查询
case 表达式
when 数值1 then 结果1
when 数值2 then 结果2
when 数值3 then 结果3
...
else 结果值n
end as 新列名
条件范围查询(case后无)
#条件范围查询
case
when 条件1 then 结果1
when 条件2 then 结果2
when 条件3 then 结果3
...
else 结果值n
end as 新列名
case查询位置在 select 和 from 之间
例:具体数值查询(case后为列名)
例:条件范围查询(case后无)
约束
稍候