Hello All, Could any well write a query for the following
scenario.
Account(table name)
No Name Amount
1 ABCD 2000.00
2 DEFG -2000.00
3 GHIJ 3000.50
4 JKLM 4000.00
5 MNOP 6000.00
O/p Should be in this format
No Name Credit Debit
1 ABCD 2000.00 0
2 DEFG 0 -2000.00
3 GHIJ 3000.50
4 JKLM 0 -4000.00
5 MNOP 6000.00 o
could any one give appropriate query for this
Thnks in Advance
Suneel Reddy
Answer Posted / shailesh
SELECT NO,NAME,DECODE(GREATEST
(AMOUNT,0),0,AMOUNT,0) "DEBIT",DECODE(GREATEST
(AMOUNT,0),0,0,AMOUNT) "CREDIT" FROM ACCOUNT
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Is like operator in sql case sensitive?
what is recursive stored procedure? : Sql dba
What is difference between inner join and cross join?
How is indexing done in search engines?
Define tables and fields in a database
How do you write a complex sql query?
Can you selectively load only those records that you need? : aql loader
What is the difference between instead of trigger and after trigger?
What is a dynamic query?
Do we need to rebuild index after truncate?
What is sharding in sql?
what is try_catch block in procedure
What are the types of variables use in pl sql?
what is an execution plan? When would you use it? How would you view the execution plan? : Sql dba
What are transaction and its controls?