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 varchar example?

546


What is your daily office routine?

1773


How do you copy a table in sql?

537


what is the difference difference between procedure and packages

9160


Explain how to use transactions efficiently : transact sql

504






What is join view in sql?

490


What is record type in pl sql?

514


Can I join the same table twice?

502


What is dynamic query?

517


Does varchar need length?

494


Explain clause in sql?

537


Can I create table without primary key?

501


What is the difference between a query and a report?

492


What happens when a trigger is associated to a view?

482


How is indexing done in search engines?

505