I’m having issues with the following case statement. I figure I can do it two ways but neither are working for me. I have two columns I’m using to derive the data.
Basically the criteria is as follows:
When erpol.n_pol is blank, use idv.n_pol, otherwise use erpol.n_pol.
I want to incorporate that if they are both blank – use ks.n_pol. Another way of identifying when to use ks.n_pol is if the first 3 letters of dt.n_pol are “OAC” which I have also tried as you can see.
Any help is greatly appreciated!
It is working now as is (with the substring commented out) I just need to be able to add the “if they are both blank use ks.n_pol to it”.
,dt.i_pol as "Policy_Number"
, (case
when erpol.n_pol is null then idv.n_pol
/*when substr(dt.i_pol,1,3)= 'OAC' then ks.n_pol*/
else erpol.n_pol end) as "Policy_Name"
,0 as "Division_Number"
,d_dby as "Disability_Date"
,0 as "Months_Since_Disability_Date"
,0 as "First_Payment_Date"
,0 as "Last_Payment_Date"
,0 as "Last_Benefit_Paidto_Date"
,dys as "Days_Since_Last_Paidto"
from dt
You can use
COALESCEeg
If there’s a danger of all 3 being null, then add a default to the end