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 is dml statement?

513


What is basic structure of pl sql?

494


what does it mean to have quoted_identifier on? What are the implications of having it off? : Sql dba

524


what are all the common sql function? : Sql dba

580


How do I enable sql encryption?

516






What is varchar sql?

613


When you have to use a default "rollback to" savepoint of plvlog?

715


What is column?

543


What is procedure in pl sql?

532


How can you maintain the integrity of your database on instances where deleting an element in a table result in the deletion of the element(s) within another table?

661


Explain architecture of sql server notification services?

618


What are the types of dbms?

544


What is parameter substitution in sql?

521


mention if it is possible to import data directly from t-sql commands without using sql server integration services? If yes, what are the commands? : Transact sql

559


Explain the difference between triggers and constraints?

512