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 / saravana sundar

select sno,name,decode(sign(amount),1,0,amount)debit,decode
(sign(amount),-1,0,amount)credit from account
/

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a foreign key be a duplicate?

497


How does stored procedure reduce network traffic?

531


What is integrity in sql?

547


Should I use mbr or gpt?

531


What is sql injection owasp?

538






What are different types of tables in sql?

522


What is the function that is used to transfer a pl/sql table log to a database table?

540


What is difference between pl and sql?

526


What is dcl in sql?

520


What is union and union all keyword in sql?

557


How do you delete duplicates in sql query using rowid?

531


What will you get by the cursor attribute sql%found?

530


Write the command to remove all players named sachin from the players table.

721


Can we create clustered index without primary key?

517


What is union and union all keyword in sql and what are their differences?

564