sql - 比较 SQL 案例语句中的 3 个变量
问题描述
我正在比较表中的 3 个变量值,因为我正在使用 case 语句。
这是桌子的图像。
我正在尝试的是这个 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;
推荐阅读
- bigcommerce - 我正在尝试捆绑项目但无法获得成功的结果
- php - 在 000webhost 上使用 fpdf 在 PHP 中创建 pdf 时出现一些错误
- javascript - 下拉 Onchange 并将 JavaScript 值传递给 PHP
- php - Google People API / 方法:contactGroups.list
- javascript - WebAssembly 的功能大吗?
- c# - VB 与 C# — CType 与 ChangeType
- swift - Firestore 查询选项 swift
- php - Mysql 服务器于 2006 年消失 - 仅与 CRON 和 ajax 一起使用
- angular - ngx-datatable - 材质主题路由器动画
- apache-kafka - kafka流窗口计数输出不可读