Hello All, Could any well write a query for the following
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
Answers were Sorted based on User's Feedback
Answer / 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
|Is This Answer Correct ?||10 Yes||0 No|
Answer / saravana sundar
(sign(amount),-1,0,amount)credit from account
|Is This Answer Correct ?||5 Yes||0 No|
Answer / ehtesham malik
Select no,name, 0 Debit, amount Credit
where amount >0
Select no,name, amount Debit, 0 Credit
where amount < 0
|Is This Answer Correct ?||2 Yes||0 No|
Answer / shailesh
(AMOUNT,0),0,0,AMOUNT) "CREDIT" FROM ACCOUNT
|Is This Answer Correct ?||1 Yes||0 No|
Answer / john bershan
the query which you have posted will work if the amount
value is greater than zero and will not work in the case
when the vale s zero as it will throw divisor is equal to
zero.please check it.
|Is This Answer Correct ?||0 Yes||0 No|
Types of cursors and explanation each of them ?
What does the base_object_type column shows in the user.triggers data dictionary view?
Is mariadb a nosql database?
What is implicit cursor in pl sql?
how to implement one-to-one, one-to-many and many-to-many relationships while designing tables? : Sql dba
Fetch an entire row from the employees table for a specific employee ID:
What is sql performance tuning?
Define implicit and explicit cursors.
What are the properties of a transaction?
What is an alias command?
How we can create a table in pl/sql block. Insert records into it? Is it possible by some procedure or function? Please give example?
What is an invalid partition table?