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 / vijay sultampur

Select No No,Name Name,Decode(Amount,Abs(Amount),Amount,0)
Credit, Decode(Amount,Abs(Amount),0,Amount) Debit
From Account;

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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

579


How many types of functions are there in sql?

498


What is difference between ms sql and mysql?

474


how are mysql timestamps seen to a user? : Sql dba

557


What is recursive stored procedure?

593






What are the uses of merge?

716


What are all different types of collation sensitivity?

523


What is the purpose of the partition table?

540


Which is faster truncate or drop?

552


What is sql profiler in oracle?

556


what are the different type of normalization? : Sql dba

550


List the ways to get the count of records in a table?

503


What is a relationship and what are they?

576


Can we use distinct and group by together?

582


What are the syntax and use of the coalesce function?

549