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 / shailesh

SELECT NO,NAME,DECODE(GREATEST
(AMOUNT,0),0,AMOUNT,0) "DEBIT",DECODE(GREATEST
(AMOUNT,0),0,0,AMOUNT) "CREDIT" FROM ACCOUNT

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of count (*) in sql?

542


What do you mean by “trigger” in sql?

618


When do we use triggers?

583


Can we insert data into materialized view?

508


What is the use of partition by in sql?

514






How to use transactions efficiently : transact sql

540


How to move files from one directory to another in pl sql?

642


Why procedure is used in sql?

531


Which is faster view or stored procedure?

501


What is an inconsistent dependency?

579


How do I run a script in sql developer?

489


Whis is not false in primary key?

975


What is inner join in sql?

584


Does access use sql?

557


what is the difference between inner and outer join? Explain with example. : Sql dba

546