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
what is the stuff function and how does it differ from the replace function? : Sql dba
Which sql statement is used to return only different values?
1) Synonyms 2) Co-related Subquery 3) Different Jobs in Plsql 4) Explain Plan 5) Wrap 6) Query Optimization Technique 7) Bulk Collect 8) Types of index 9) IF primary key is created then the index created ? 10) Foreign Key 11) Exception Handling 12) Difference Between Delete and Trunc 13) Procedure Overloading 14) Grant Revoke 15) Procedure Argument types. 16) Functions. 17) Joins
Can we use view in stored procedure?
What is the difference among union, minus and intersect?
what is collation? : Sql dba
What is a data definition language?
Explain the difference between sql and mysql.
When do we use triggers?
How do I create a sql script?
What is the difference between partition and index?
Which normal form is best?
Does group by remove duplicates?
Which software is used for pl sql programming?
What are the advantages of indexing?