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 / saravana sundar

select sno,name,decode(sign(amount),1,0,amount)debit,decode
(sign(amount),-1,0,amount)credit from account
/

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is record in pl sql?

523


What is an alias command?

584


what is a scheduled jobs or what is a scheduled tasks? : Sql dba

564


What is the full form of sql?

540


What is the use of triggers?

548






what is the difference between a web-garden and a web-farm? : Sql dba

572


What is raid? How does it help storage of databases?

612


what is the syntax used for partition in tsql? : Transact sql

552


What are its different types of dbms?

548


What are the types of sql commands?

559


What's the procedure?

502


what is 'trigger' in sql? : Sql dba

570


Is like operator in sql case sensitive?

519


Does sql support programming?

566


What is dynamic sql in pl sql?

507