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

x
?
Solved

Ouput integer as postive

Posted on 2011-04-26
2
Medium Priority
?
189 Views
Last Modified: 2012-05-11
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
Comment
Question by:GRChandrashekar
2 Comments
 
LVL 39

Accepted Solution

by:
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

by:jimyX
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

Open in new window

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

826 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question