I am inserting data into a temp table and want a conditional statement on one item that will insert the code description if found in the code table or want the code if not found. All of the joins not shown are returning the correct values, so they are not a factor in my issue. My insert select statement looks something like...
select DISTINCT P.POSITION_ID,
PPI.HRPER_ID,
PS.PERSTAT_PRIMARY_POS_ID,
P.POS_TITLE,
P.POS_START_DATE,
P.POS_END_DATE,
DIV.DIV_DESC,
DEP.DEPTS_DESC,
<the following is the logic I want but I can't get sql to like no matter what I try>
if (V1.VAL_EXTERNAL_REPRESENTATION is NULL) then
P.POS_CLASS;
else
V1.VAL_EXTERNAL_REPRESENTATION;
end if
V2.VAL_EXTERNAL_REPRESENTATION,
PPF.POSPAY_FNDG_GL_NO,
PPF.POSPAY_FNDG_PCT,
PPF.POSPAY_FNDG_PROJ_ID,
select DISTINCT P.POSITION_ID,
PPI.HRPER_ID,
PS.PERSTAT_PRIMARY_POS_ID,
P.POS_TITLE,
P.POS_START_DATE,
P.POS_END_DATE,
DIV.DIV_DESC,
DEP.DEPTS_DESC,
<the following is the logic I want but I can't get sql to like no matter what I try>
if (V1.VAL_EXTERNAL_REPRESENTATION is NULL) then
P.POS_CLASS;
else
V1.VAL_EXTERNAL_REPRESENTATION;
end if
V2.VAL_EXTERNAL_REPRESENTATION,
PPF.POSPAY_FNDG_GL_NO,
PPF.POSPAY_FNDG_PCT,
PPF.POSPAY_FNDG_PROJ_ID,