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
What are expressions?
What is the difference between join and natural join?
Which table is left in join?
What is the default isolation level in sql server? : Transact sql
What is multiple partition?
how would you enter characters as hex numbers? : Sql dba
How do I view stored procedures?
Is sql a case sensitive language?
Is record in oracle pl sql?
What is sql and its types?
How to handle bulk data?
how to concatenate two character strings? : Sql dba
What are the different ddl commands in sql?
what is the difference between mysql_fetch_object and mysql_fetch_array? : Sql dba
What is difference between sql function and stored procedure?