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

Answer Posted / omi naik

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

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different sql languages?

552


What is posting?

621


What is online transaction processing (oltp)?

607


how to use case expression? : Sql dba

561


How can you know that statistics should be updated?

621






What is query syntax?

525


Does inner join return duplicate rows?

530


Does mysql_real_escape_string prevent sql injection?

545


What is the use of pl/sql table?

565


What is the use of & in pl sql?

544


how many groups of data types? : Sql dba

578


What are different types of sql?

572


Can we commit inside a trigger?

557


What are records give examples?

576


Does sap use sql?

527