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...

in account table
account type amount
ac1 credit 300
ac2 debit 5000
ac3 credit 3000
ac1 debit 4000
ac3 debit 2000
ac2 credit 4000
write a query how to get sum of credit & sum of debit

Answer Posted / vijay patil

-----------table lavel credit debit
select
sum(case when type=credit then isnull(amount,0)end)sum_credit,
sum(case when type=debit then isnull(amount,0) end)sum_debit
from account_table;

OR -----------table lavel credit debit

select type,sum(amount)amt
from account_table
group by type;

OR (at accont lavel credit debit)

select account,type,sum(amount)amt
from account_table
group by account,type;

Is This Answer Correct ?    8 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I get column names from a table in oracle?

985


When system tablespace is created?

972


How does oracle handle read consistency?

1052


is there a tool to trace queries, like profiler for sql server?

1078


What are the differences between primary key and unique key?

949


What is a nested table and how is it different from a normal table?

988


Iam learning oracle developer 2000.. can anyone give me then tutorials sites or PDF related to developer 2000 please send me the details @ mak2786@gmail.com thanks Arun

2130


What is the difference between truncate & delete command?

1125


How to define default values for formal parameters?

985


How to assign data of the deleted row to variables?

1015


Where are the settings stored for each instance in oracle?

1063


How to select an oracle system id (sid)?

1020


Will you be able to store pictures in the database?

1063


What is oracle database 10g express edition?

1075


How to convert a string to a date in oracle database?

1002