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

interview questions with answer for cts

2571


How to sort the query output in oracle?

1009


What are the common oracle dba tasks?

1127


Which are the five query types available in oracle?

937


When system tablespace is created?

1022


How to save query output to a local file?

1006


What is the difference between alert log file and tarce file ?

2155


How to set up autotrace for a user account?

1037


How can I combine multiple rows into a comma-delimited list in oracle?

1044


What is materialized view in Oracle?

1062


How to connect to oracle using service name instead of sid?

999


What is open database communication (odbc) in oracle?

989


Does oracle partitioning improve performance?

970


Point out the difference between user tables and data dictionary?

970


What are the advantages of oracle?

1018