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 / saravana sundar
select sno,name,decode(sign(amount),1,0,amount)debit,decode
(sign(amount),-1,0,amount)credit from account
/
Is This Answer Correct ? | 5 Yes | 0 No |
Post New Answer View All Answers
What is a ddl command?
What is foreign key and example?
What are schema-level triggers?
How do I sort a table in sql?
what is the difference between a having clause and a where clause? : Sql dba
What are all different types of collation sensitivity?
how to do backup entire database? : Transact sql
Why do we use function in pl sql?
What is the use of procedures?
What are stored procedures in mysql?
How do sql databases work?
Table 1: col1 Timestamp ---------------- 01-mar-2012 11:12:46 Table 2: col2 Timestamp -------------------- 01-mar-2012 11:12:10 01-mar-2012 11:11:23 Write a query to display a row with table2 col2 value less than tabl1 col1 value. Maximum timestamp value previous to table1 col1 value. Display a result as: Col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10
What are few of the schema objects that are created using PL/SQL?
What is cascade in sql?
Is a foreign key always unique?