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)
我需要将 case/if else 条件应用于上面的 select 语句。我试过了,但我得到了一个错误。那个错误是
ORA : 00923: from keyword not found where expected
实际上我想应用这样的 if-else 条件:
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
任何人都可以检查我的陈述并提出任何建议吗?