Link to home
Start Free TrialLog in
Avatar of GRChandrashekar
GRChandrashekarFlag for India

asked on

Ouput integer as postive

SELECT BILLDATE,
       MONTHLYBILL_ID,
       BALANCEAMOUNT,
 
       CASE WHEN BALANCEAMOUNT < 0 THEN 'C' ELSE 'D' END AS DEBITCREDIT
  FROM MONTHLYBILL
 WHERE BILLDATE = NVL (TO_DATE ('', 'DD/MM/YYYY'), BILLDATE)
       AND MEMBER_ID = 4

In the above query, I am displaying all negative values as C and positive values as D.
But I dont want negative sign to appear in output
If I do ABS(Balanceamount) then case becomes D if integer is -ve. I want the case to remain as C but show -ve as +ve. How can I do this
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jimyX
jimyX

What happens when you execute this one:
SELECT BILLDATE,
       MONTHLYBILL_ID,
       ABS(BALANCEAMOUNT),
 
       CASE WHEN BALANCEAMOUNT < 0 THEN 'C' ELSE 'D' END AS DEBITCREDIT
  FROM MONTHLYBILL
 WHERE BILLDATE = NVL (TO_DATE ('', 'DD/MM/YYYY'), BILLDATE)
       AND MEMBER_ID = 4

Open in new window