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

Answer Posted / ajit nayak

select no, name,
case sign(amt) when 1 then amt else 0 end crd,
case sign(amt) when -1 then amt else 0 end debt
from account;

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the advantage of index in sql?

536


What do you mean by stored procedures?

545


Explain the working of foreign key?

542


Can we rollback truncate?

534


What are local and global Indexes and where they are useful.

924






How many types of triggers are there in pl sql?

572


How many rows can sqlite handle?

581


What is the maximum number of rows in sql table?

543


What is the use of desc in sql?

490


what is the command line end user interface - mysql? : Sql dba

500


What is package in pl sql with an examples?

545


What is trigger price?

538


what is row? : Sql dba

705


What are different joins used in sql?

548


Is t sql a programming language?

539