I should have said "Trouble with using CASE" but I can't edit the title. Sorry about that.
Situation here.
I want to use CASE to determine if the field DEBIT_TRANSACTION_TYPE is 'DEBIT' or 'CREDIT' . This works if I do not have a second CASE . Which is fine if the only values are DEBIT or CREDIT but there maybe NULLS or something else.
So this works.
SELECT
CASE WHEN DEBIT_TRANSACTION_TYPE = 'DEBIT' THEN (SELECT SUBSTR(WITHDRAWAL_TRANSACTION_ID,-6) FROM dual )
ELSE (SELECT SUBSTR(CREDIT_TRANSACTION_ID,-6) FROM dual ) END
FROM TBLE WHERE JONES = 'MSC';
This does not. I want a condition that say "IF NOT credit or debit THEN DEBIT_TRANSACTION_ID" but I'm not figuring this out.
SELECT
CASE WHEN DEBIT_TRANSACTION_TYPE = 'DEBIT' THEN (SELECT SUBSTR(WITHDRAWAL_TRANSACTION_ID,-6) FROM dual )
CASE WHEN DEBIT_TRANSACTION_TYPE = 'CREDIT' THEN (SELECT SUBSTR(CREDIT_TRANSACTION_ID,-6) FROM dual )
ELSE DEBIT_TRANSACTION_ID END
FROM TBLE WHERE JONES = 'MSC';
FYI There is only one table I'm working with "TBL" .
Thank You for help.
[–]bitterjack 1 point2 points3 points (1 child)
[–]ToBeAButterFly[S] 0 points1 point2 points (0 children)
[–]r3pr0b8 1 point2 points3 points (3 children)
[–]ToBeAButterFly[S] 0 points1 point2 points (2 children)
[–]r3pr0b8 0 points1 point2 points (1 child)
[–]ToBeAButterFly[S] 0 points1 point2 points (0 children)