判断三角形
问题:给出三角形的三条边的长度,判断是否形成三角形
思路:
任意两边之和 > 第三边
函数:
if(表达式,‘Yes’,‘No’)--- 表达式为1,输出yes,表达式为0,输出no
case when 表达式 then ‘Yes’ else ‘No’ --- 表达式为1,输出yes,表达式为0,输出no
SQL:
1. select x,y,z,if(x+y>z and x+z>y and y+z>x,'Yes','No') as 'triangle' from triangle
2. 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