我有这段代码
select A,B,C,
case
when A = B = C then'Equilateral'
when A + B < C then 'Not A Triangle'
when (A = B and B != C) or (A = C and B != A) or ( B = C and A != B ) then "Isoceles"
else "Scalene"
end,
from Triangles;
我只希望它显示字符串equilateral
,not a triangle
。不显示列的内容。我该怎么做?
答案 0 :(得分:2)
只需选择您想要的内容即可。看起来似乎是:
select (case when A = B and B = C then 'Equilateral'
when A + B < C then 'Not A Triangle'
when (A = B and B <> C) or (A = C and B <> A) or ( B = C and A <> B )
then 'Isoceles'
else 'Scalene'
end)
from Triangles;
请注意,我在表达式中替换了标准SQL运算符。由于case
的优先级和修复逻辑,这可以是:
select (case when A + B < C or A + C < B or B + C < A then 'Not A Triangle'
when A = B and B = C then 'Equilateral'
when A = B or A = C or B = C
then 'Isoceles'
else 'Scalene'
end)
from Triangles;
这假定A
,B
和C
都是非负面的。