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

Display the total debit counts, total credit counts, sum of
total debits, sum of total credits from an employee's
transaction table (a single table) containing the following
columns.
Transaction_number
Transaction_amount
Transaction_date
Transaction_type --> tells if the amount is a credit or a
debit.

As the query alone is important, the table is left with
specifying just the field's name. Pls help me with this
query.

Answer Posted / apoorva garg

select count(decode(trim(transaction_type),'D',1)) total_debits,
count(decode(trim(transaction_type),'C',1)) total_credits,
sum(decode(trim(transaction_type),'D',transaction_amount)) total_debits_amt,
sum(decode(trim(transaction_type),'C',transaction_amount)) total_credits_amt
from transaction

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you delete duplicates in sql query using rowid?

946


Can we enter data in a table in design view?

967


what is 'mysqladmin' in mysql? : Sql dba

1024


What is constant in pl sql?

1020


Why truncate is used in sql?

1003


Can we use having without group by in sql?

982


what is the functionality of the function htmlentities? : Sql dba

951


What is trigger explain with example?

1034


What is scalar data type in pl sql?

1066


what's the difference between a primary key and a unique key? : Sql dba

1046


What is sqlcommand?

1026


How many sql are there?

995


What is mutating table error?

1176


What is string data type in sql?

1137


what is 'mysqlimport'? : Sql dba

1046