在SQL case语句中比较3个变量

赛义德·阿萨兰·侯赛因

我正在使用case语句比较表中的3个变量值。

这是表格的图像。

在此处输入图片说明

我正在尝试的是此SQL选择查询。

select a,b,c,
case(
    when (a=b=c) then "Equilateral"
    when a!=b!=c then "Scalene"
    when a=b!=c or a!=b=c then "Isosceles"
    else "Not A Triangle"
    end as Text
)
from TRIANGLES;

下图显示了我遇到的错误。

在此处输入图片说明

谁能指导我我做错了什么?

骄傲的埃德

重写您的表达式,不支持此操作。

select a,b,c,
case
    when (a=b) and (b=c) then 'Equilateral'
    when (a!=b) and (b!=c) then 'Scalene'
    when (a=b and b!=c) or (a!=b and b=c) then 'Isosceles'
    else 'Not A Triangle'
    end as [Text]

from triangles;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章