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 / ajit nayak
select no, name,
case sign(amt) when 1 then amt else 0 end crd,
case sign(amt) when -1 then amt else 0 end debt
from account;
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What are the types of index in sql?
What is cascade in sql?
Which join condition can be specified using on clause?
What view means?
What is the difference between cluster and non-cluster index?
what are date and time intervals? : Sql dba
What if we write return in procedure?
What is primary key sql?
How do you add a column to a table?
Name the operator which is used in the query for pattern matching?
What is secondary key?
What is cartesian join in sql?
how to use regular expression in pattern match conditions? : Sql dba
What is a sql trace file?
How to select all records from the table?