Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 largest value that can be stored in a byte data field?

999


What is gpt format?

927


How do you copy a table in sql?

1047


Is inner join same as self join?

1107


How exception is different from error?

1002


Is and as keyword in pl sql?

942


How many sectors are in a partition?

1061


what is datawarehouse? : Sql dba

999


What are the benefits of pl/sql packages?

1090


What is cost in sql execution plan?

962


What are some predefined exceptions in pl/sql?

1143


What is sql in java?

1064


How can I tell if sql is running?

1032


What is rank () in sql?

923


How does sql*loader handles newline characters in a record? : aql loader

1022