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 / ehtesham malik

Select no,name, 0 Debit, amount Credit
from temp
where amount >0
union
Select no,name, amount Debit, 0 Credit
from temp
where amount < 0

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is dynamic query?

641


Which data type is a composite type?

629


Is it possible to create startup or shutdown trigger for on-schema?

675


What is field delimiter?

712


what is csv? : Sql dba

669






What are types of exception?

605


what is 'mysqldump'? : Sql dba

665


how can we optimize or increase the speed of a mysql select query? : Sql dba

594


What is lookup table in sql?

694


What is sql data?

628


Explain isolation levels. : Transact sql

659


How to set up sql*plus output format in oracle?

692


what is acid property in database? : Sql dba

659


How do I pipe the output of one isql to another?

620


Does a join table need a primary key?

625