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

What steps server process has to take to execute an update statement?

705


How does pl sql work?

704


Under what condition it is possible to have a page level lock and row lock at the same time for a query? : Transact sql

742


How can you fetch first 5 characters of the string?

707


what are the limitations of identity column? : Transact sql

822






What are user defined functions?

759


How can I see all tables in sql?

727


Is postgresql a server?

734


What is sql injection owasp?

725


What are the ddl commands?

716


What jobs use sql?

721


What are different types of tables in sql?

698


How to select 10 records from a table?

836


How to pronounce postgresql?

759


Does pl/sql support create command?

741