This discussion is archived
5 Replies Latest reply: Sep 13, 2013 1:01 PM by user515689 RSS

embedded conditional within select statement

user515689 Newbie
Currently Being Moderated


Hi folks.

 

I'm trying to set up a conditional block within a select statement. I've browsed the forums and seen suggestions with DECODE and the recurring insistence that IF/ELSE won't or can't work within non PL/SQL, which is what this would be.

 

I'm trying to plug in a simple string value if a column's value is null. The WHEN block either doesn't work either or I'm doing it wrong, but I'd take any suggestions from those of you more knowledgeable than I on this.

 

Here's the block:

------------------

SELECT c.CHCTRLID AS "CC ID", c.STATUS3, b.VPTIMSTAMP,
a.VP_DATE AS "Submit Date", a.CRITI_EXP_DT AS "Critical Date", c.REQ_TYPE, c.SUBJLETTER,

c.PGCOUNT AS "Page Total", c.EFFECT_PGCOUNT,
c.PUBTYPE AS "Publication Type", c.COMPLEXITYLEVEL,
c.PUBDATE, a.BRANCH, a.BRANCH_SEC, a.PRIORITY, c.WRITER, a.REQ_INFO_DESCRIPT, a.DEPT,

Abs(Round((PUBDATE-VPTIMSTAMP),0)) AS "SLA Level in Days",

 

 

--   WHEN PUBDATE IS NULL
--   then return 'n/a' AS "Secondary SLA",
--    WHEN OTHERS THEN
--    RETURN Abs(Round(SYSDATE-VPTIMSTAMP),0)) AS "Secondary SLA",
 

a.OPS_MAN_CHG, a.OPS_MAN_PPCHAP,a.STRATEGY_UPDATE, a.CRITICAL_EXP

FROM CHG_CTRL_ADM b INNER JOIN CHG_CTRL_USR a
ON b.CHCTRLID = a.CHCTRLID
INNER JOIN ADM_SUPP_INDX c ON b.CHCTRLID = c.CHCTRLID

WHERE c.STATUS3 != 'Cancelled'  AND a.VP_DATE >   '04-APR-11'
ORDER BY a.CHCTRLID

---------------------------

I've commented out the WHEN block because it wouldn't work, but essentially, that's what I'm trying to accomplish.

 

Thank you.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points