0
我有以下case語句用於加載代碼表。我必須要找到的記錄數裝入碼表 與TRAN_CODE = 7時[GLI-SRC =「8」如何在基於SQL CASE語句的WHERE條件中過濾記錄
INSERT INTO codes
SELECT CASE
WHEN [cash-amt] > 0 THEN '1'
WHEN [prod-n] = '42'
AND [tran-code] IN ('-1', '-2', '-3') THEN '17'
WHEN [gli-src] = '8' THEN '7'
WHEN [prod-n] = '42'
AND [gli-src] = 'L'
AND [tran-code] IN ('1', '2', '3') THEN '7'
WHEN [gli-src] = 'L'
AND [prod-n] = '60'
AND [tran-code] IN ('4', '5', '6') THEN '7'
ELSE '4'
END AS TRAN_CODE
FROM txn
這是我曾嘗試雖然我很困惑如何過濾掉其他情況。
select COUNT(1) from txn
where [CASH-AMT] <= 0
and
.
.
.
. ????
and [gli-src] = '8'
@ReeyaOberoi你什麼意思?我不明白你的問題 – Lamak
對不起,我知道了。萬分感謝! –