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 / mkumar.it

select no, name,
case amount/abs(amount) when 1 then amount else 0 end credit,
case amount/abs(amount) when -1 then amount else 0 end Debit
from account

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is sql server agent? : Sql dba

599


Explain constraints in sql?

569


Which kind of parameters cannot have a default value in pl sql?

593


which command using query analyzer will give you the version of sql server and operating system? : Sql dba

522


What are sql injection vulnerabilities?

497






Can you selectively load only those records that you need? : aql loader

607


Which is better trigger or stored procedure?

498


What program will open a mdb file?

494


What does sql stand for?

542


What is fmtonly in sql?

527


What is a sql statement?

529


What is percent sign in sql?

713


What is the source code of a program?

505


describe mysql connection using mysql binary. : Sql dba

549


How to create your own reports in sql developer?

538