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
How to use sql*plus built-in timers?
how would concatenate strings in mysql? : Sql dba
Differences between Oracle 9i and 10g (Probably in terms of SQL and PL/SQL)?
What is the difference between sql and t sql?
What are the different types of constraints?
discuss about myisam key cache. : Sql dba
What are sql queries used for?
First round ------------------- - Procedure - Packages - Views - Virtual tables - Can we use dcl with in function? - Joins and few scenarios - Triggers and its type - Pragma, type and its functionality - How to create db link in oracle - Materialized view - How to find duplicate values from table? - Cursor and its functionality - Write a script to display friday and its date from a entire year. - Exception Handling Second round ------------------------ Gave a scenario like. Need to write a function to perform. When user try to change a password. It must not be last five password and a given password can be combination of characters, symbols, upper and lower case.
what is data control language? : Sql dba
Explain the purpose of %type and %rowtype data types?
How can we optimize a sql query?
What is sql keyword?
Is oracle and sql same?
what is an execution plan? When would you use it? How would you view the execution plan? : Sql dba
What is the usage of when clause in trigger?