我正在尝试解决基于数据库在三种三角形之间进行选择的普通查询

问题描述 投票:0回答:1

=之前的语法错误处获取错误

select t_name, 
case 
    when a=b then 'Isoscels' 
    when a=b=c then 'Equilateral'  
    when a<>b<>c then 'Scalene'  
    when (a+b)<c then 'Not A Triangle' 
end as t_name 
from triangles 
database sql-server-2008 switch-statement case
1个回答
0
投票

我怀疑这是您想要的逻辑:

SELECT
    t_name,
    CASE WHEN a = b THEN 'Isoscels'
         WHEN a = b AND b = c AND a = c THEN 'Equilateral'
         WHEN a <> b AND b <> c AND a <> c THEN 'Scalene'
         ELSE 'Not A Triangle' END AS t_name
FROM triangles;

据我所知,不可能在SQL Server中链接等式表达式,因为您可能可以用其他语言(例如JavaScript或PHP)来做。

© www.soinside.com 2019 - 2024. All rights reserved.