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 / mkumar.it
select no, name,
case amount/abs(amount) when 1 then amount else 0 end credit,
case amount/abs(amount) when -1 then amount else 0 end Debit
from account
| Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
How do sql databases work?
How can get second highest salary in sql?
Explain cursor types?
what are the join types in tsql? : Transact sql
What is the most restrictive isolation level? : Transact sql
What is autocommit sql?
What is a trigger in sql?
What is auto increment in sql?
How can I see all tables in sql?
What is the difference between inner join and natural join?
What is the use of <> sql?
Is inner join same as self join?
what is a database? : Sql dba
What is sql analyzer?
What are all types of user defined functions?