Toad World® Forums

Replacing Null in one column with value from another column

Hi I am a newbie to Toad Data Point at work and I am trying to figure out with the code below how to replace the Location Age with SR Age if Location Age is NULL. My problem is the column was created with a formula in order to get the value needed so I am hitting a wall to tell it what I want. Any help would be greatly appreciated.

Select
H.INQY_NB "Service Request Number"
,OH.ORG_NM "Assigned to Location"
,H.INQY_STAT_CD "Status"
,CASE WHEN H.INQY_STAT_CD = 'Closed' THEN (days(H.INQY_CLSD_TM)- days(H.INQY_CRET_TM) +1) END "SR Age"
,CASE WHEN H.INQY_STAT_CD = 'Closed' THEN date(H.INQY_CLSD_TM) - date(H.LOCN_TRF_TM) +1 END "Location Age"
,H.INQY_AREA_NM "Area"
,H.INQY_SUB_AREA_NM "Sub Area"
,CAST (H.INQY_CLSD_TM as Date) "Closed Date"
,B.INDV_RACF_ID "Closed by RACF"
,BA.CNTC_EMPE_FULL_NM "Closed by Full Name"
,OC.ORG_NM "Created Location"
,AG.AGEY_OF_REC_CD "AOR Number"
,AG.ORG_NM "Agency Name"
,H.HCC_ID "HCC ID"

How about this:

Select
H.INQY_NB "Service Request Number"
,OH.ORG_NM "Assigned to Location"
,H.INQY_STAT_CD "Status"
,CASE WHEN H.INQY_STAT_CD = 'Closed' THEN (days(H.INQY_CLSD_TM)- days(H.INQY_CRET_TM) +1) END "SR Age"

, CASE
WHEN CASE
WHEN H.INQY_STAT_CD = 'Closed'
THEN date(H.INQY_CLSD_TM) - date(H.LOCN_TRF_TM) +1
END IS NULL
THEN CASE WHEN H.INQY_STAT_CD = 'Closed' THEN (days(H.INQY_CLSD_TM)- days(H.INQY_CRET_TM) +1) END
END AS "Location Age"

,H.INQY_AREA_NM "Area"
,H.INQY_SUB_AREA_NM "Sub Area"
,CAST (H.INQY_CLSD_TM as Date) "Closed Date"
,B.INDV_RACF_ID "Closed by RACF"
,BA.CNTC_EMPE_FULL_NM "Closed by Full Name"
,OC.ORG_NM "Created Location"
,AG.AGEY_OF_REC_CD "AOR Number"
,AG.ORG_NM "Agency Name"
,H.HCC_ID "HCC ID"