SELECT HQRH_BADGENO,
HQRH_SHIFT,
HQBD_BADGENAME,
HQRH_DISCRRECONCILE,
HQRH_ADJUSTAMOUNT,
HQRH_DISCRADJUSTMENT,
CASE HQRH_DISCRRECONCILE
WHEN 'HQRH_DISCRRECONCILE <0' THEN
'HQRH_ADJUSTAMOUNT'
WHEN 'HQRH_ADJUSTAMOUNT>0' THEN
'HQRH_ADJUSTAMOUNT'
WHEN 'HQRH_DISCRADJUSTMENT<0' THEN
'HQRH_DISCRADJUSTMENT * (-1)'
ELSE
'HQRH_DISCRRECONCILE>0'
END
FROM HQ_CASHRECONCILEHEADER, HQ_BADGE
WHERE HQ_CASHRECONCILEHEADER.HQRH_PLAZANO = HQ_BADGE.HQBD_PLAZANO
and HQ_CASHRECONCILEHEADER.HQRH_BADGENO = HQ_BADGE.HQBD_BADGENO
AND (HQ_CASHRECONCILEHEADER.HQRH_OPERATIONALDATE =
TO_DATE(:dtstart, 'DD/MM/YYYY'))
AND (HQ_CASHRECONCILEHEADER.HQRH_PLAZANO = :plazano)
I need to apply case/if else condition to above select statement. I tried but I am getting an error. That error is
ORA : 00923: from keyword not found where expected
Actually I want to apply an if-else condition like this:
if colA -ve then ' here colA = excess
if colB +ve then paid = colB ' here colB = paid
elseif colC -ve then unpaid = colc * -1 ' here colC = unpaid
else do nothing
else if colA +ve then excess = cola
else do nothing
Can anyone please check my statement and give any suggestions?