SQL知识点:条件判断用法(case when和if)
条件判断
点击查看代码
# 使用case when
/*
select
x,y,z,
case
when x+y>z and x+z>y and y+z>x then 'Yes' else 'No'
end as triangle
from
triangle
*/
# 使用if
select
x,y,z,
if(x+y>z and x+z>y and y+z>x,'Yes','No') AS triangle
from
triangle
浙公网安备 33010602011771号