我有以下查询:
IndexedSeq[X]
我想重写查询,以便它包含SELECT IMALAC.DANOCENBROJ,
'1' as REZULTAT
FROM IMALAC
LEFT JOIN RACUNIL
ON IMALAC.ID = IMALACID
WHERE RACUNIL.STATUS = 1
AND (
RACUNIL.VIDSMETKA = 1
OR RACUNIL.VIDSMETKA = 5
OR RACUNIL.VIDSMETKA = 7
OR RACUNIL.VIDSMETKA = 8
OR RACUNIL.VIDSMETKA = 9
)
语句,该语句应该充当case
部分的if
/ else
语句
特别是,条件应该是:
where
子句后的代码为where
,则true
= 1 任何?
答案 0 :(得分:4)
如果我理解正确,你想要这个:
SELECT IMALAC.DANOCENBROJ,
CASE
WHEN RACUNIL.STATUS = 1 AND RACUNIL.VIDSMETKA IN (1,5,7,8,9)
THEN 1
ELSE 0
END as REZULTAT
FROM IMALAC
LEFT JOIN RACUNIL
ON IMALAC.ID = IMALACID
;