我有一个表格,其中有4列 表格名称:充值
------------------------------------
Status | Adjustment | Kisok | Done |
Yes | 232 | Abc | ok |
NO | Null | Adc | No |
-------------------------------------
我希望状态=是 当调整,Kisok和完成不为空时 如果状态=否 然后Adjustment,Kisok和Done可以同时为null和Not null
我希望使用算术SQL查询(和(或))中的此查询 如果不 大小写,如果还可以 如果您能帮助我,那我很好
我知道Logic很好,但是我不清楚语法
此查询有误>>
SELECT Status1,csdoneby,kioskdoneby,adjtmentstype,
(CASE
WHEN csdoneby,kioskdoneby,adjtmentstype, IS NOT NULL THEN Status1='yes'
ELSE Status='No'
END as Test)
FROM topup;
答案 0 :(得分:0)
您应将条件分配给每一列
SELECT Status1, csdoneby,kioskdoneby, adjtmentstype,
CASE
WHEN csdoneby IS NOT NULL
AND kioskdoneby IS NOT NULL
AND adjtmentstype IS NOT NULL THEN 'yes'
ELSE 'No'
END as Test
FROM topup;
答案 1 :(得分:0)
这是正确的语法。
SELECT
Status1,
csdoneby,
kioskdoneby,
adjtmentstype,
CASE
WHEN csdoneby IS NOT NULL
AND kioskdoneby IS NOT NULL
AND adjtmentstype IS NOT NULL
THEN Status1='yes'
ELSE 'No'
END as Status
FROM topup
答案 2 :(得分:0)
尝试这样
SELECT Status1, csdoneby, kioskdoneby, adjtmentstype,
CASE WHEN csdoneby IS NOT NULL AND kioskdoneby IS NOT NULL AND adjtmentstype IS NOT
NULL THEN 'yes'
ELSE 'No'
END AS Test
FROM topup;