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
Is record in oracle pl sql?
How can use stored procedures in sql?
what is query cache in mysql? : Sql dba
What is an exception in PL/SQL? What are the two types of exceptions?
Which is better stored procedure or query?
What is crud sql?
Can we alter stored procedure?
How do I get sql certification?
What is the difference between local variables and global variables?
How do I view a sql database?
What is exception? What are the types of exceptions?
what is the difference between inner and outer join? Explain with example. : Sql dba
How delete a row in sql?
how would you write a query to select all teams that won either 2, 4, 6 or 8 games? : Sql dba
What is difference between ms sql and mysql?