我有下表
A B C
20 20 23
20 20 20
20 21 22
13 14 30
命名三角形,如果三角形是等边,等腰,斜角或不是三角形,我需要每次输出。
我使用了以下代码:
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;
但是我收到了这个错误:
when A = B = C then'Equilateral'
*
ERROR at line 3:
ORA-00905: missing keyword
答案 0 :(得分:1)
这是因为您必须将这些内容分别设置为A = B
和B = C
并删除,
之后的end
(因为您不再有列)< / p>
select A,B,C,
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;