[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
Solved

# Ouput integer as postive

Posted on 2011-04-26
Medium Priority
189 Views
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
0
Question by:GRChandrashekar

LVL 39

Accepted Solution

Pratima Pharande earned 2000 total points
ID: 35472834
SELECT BILLDATE,
MONTHLYBILL_ID,
ABS(BALANCEAMOUNT) as 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
0

LVL 24

Expert Comment

ID: 35472837
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
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
###### Suggested Courses
Course of the Month18 days, 9 hours left to enroll