Hello, I'm really new to writing SQL queries to query Oracle databases and could use a little assistance. I hope I'm in the correct forum.
I have a case expression as follows:
(CASE WHEN DATEa=DATEb THEN 0
WHEN DATEa> DATEb THEN NETWORKDAYS(DATEb, DATEa)
WHEN DATEa < DATEb THEN NETWORKDAYS(DATEa, DATEb)
WHEN STATUS='PENDING' THEN NULL
END) AS RESULTa,
Now what I need to be able to do is place those results in buckets, similar to this:
(CASE WHEN RESULTa < 0 THEN '<0'
WHEN RESULTa between -1 AND 6 THEN '<=5'
WHEN RESULTa >5 THEN '>5'
END) AS BUCKETa
I understand that I can't call an alias from a previous case expresson to get these desired results and I'm confused on how I could combine the two statements to get the desired bucket.
Any assistance or advice anyone could provide would be most appreciated.