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 / ehtesham malik
Select no,name, 0 Debit, amount Credit
from temp
where amount >0
union
Select no,name, amount Debit, 0 Credit
from temp
where amount < 0
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
How do I write a sql query in pgadmin 4?
What is a heap in sql?
Is pl sql different from sql?
What is the use of <> sql?
Table A Table B 1 1 2 1 3 1. Union & union all --> A Union B , A Union all B 2. Minus , Intersect --> A minus B , B Minus A , A Intersect B 3. Joins A join B , A Left Join B A Right Join B , A full Join B 4. %Type - Uses & Benifit 5. Truncate & Delete 6. Pragma Autonomus Transaction 7. how to Perform DDL from function or procedure 8. Can we have DML inside Function 9. Rank & Dense Rank diffrence 10. Water Mark in Oracle 11. Index , Can we have index in all column of table if no then why ?
What steps server process has to take to execute an update statement?
give the syntax of grant and revoke commands? : Sql dba
What is scalar and vector?
what are the t string functions available in tsql? : Transact sql
tell me about various levels of constraint. : Sql dba
How many types of tables are there?
Differentiate between syntax and runtime errors.
How many times can we commit in a loop?
how to select first 5 records from a table? : Sql dba
How does postgresql compare to mysql?