Equilateral: It's a triangle with sides of equal length.
Isosceles: It's a triangle with sides of equal length.
Scalene: It's a triangle with sides of differing lengths.
Not A Triangle: The given values of A, B, and C don't form a triangle.
A,B和C是三角形表中的列名称
SQL查询
(
SELECT distinct
CASE
when (a=b and a<>c)
or (b=c and a<>c)
or (a=c and a<>b)
then 'Isosceles'
end
from triangles
)
union
(
SELECT distinct
CASE
when a=b
and b=c
then 'Equilateral'
end
from triangles
)
union
(
SELECT distinct
CASE
when a!=b
and b!=c
and a!=c
then 'Scalene'
end
from triangles
)
union
(
SELECT distinct
CASE
when a+b<c
or b+c <a
or a+c<b
then 'Not A Triangle'
end
from triangles
);
输出
NULL
Isosceles
等边
Scalene
不是三角形
答案 0 :(得分:0)
您可以尝试:
SELECT distinct
CASE
when (a=b and a<>c)
or (b=c and a<>c)
or (a=c and a<>b)
then 'Isosceles'
when a=b
and b=c
then 'Equilateral'
when a!=b
and b!=c
and a!=c
then 'Scalene'
else 'Not A Triangle'
end
from triangles
您可以根据需要更改条件。