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 / omi naik

select no, name,
decode (sign(amount),1 , amount , 0) credit,
decode (sign(amount),-1 , amount , 0) debit
from account

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is bitemporal narrowing?

1284


How can you create an empty table from an existing table?

1057


What is the difference between rollback and rollback to statements?

1046


What is cursor explain with example?

964


What are the different ways to optimize a sql query?

928


Does sql between include endpoints?

989


How to make a copy values from one column to another in sql?

1021


Is sql harder than python?

1076


What is file based approach?

924


How to run sql statements through the web interface?

1020


what are null values? : Sql dba

937


what is error ora-03113: end-of-file on communication channel?

1148


How does join work in sql?

994


How do I pipe the output of one isql to another?

989


Is full outer join same as cross join?

949