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

Define SQL and state the differences between SQL and other conventional programming Languages?

679


What is difference between db2 and sql?

530


Are stored procedures faster than dynamic sql?

528


what is the command line end user interface - mysql? : Sql dba

501


Can 2 queries be executed simultaneously in a distributed database system?

640






When to use inner join and left join?

524


Write a sql query to convert all character to uppercase after hypen.

957


hi,i plan to put experience on PLSQL ,can anyone suggest me for any institutes in bangalore or how to prepare for interviews

1525


What is the difference between inner join and outer join?

527


What is the usage of distinct keyword?

627


What are the different types of constraints?

561


explain about mysql and its features. : Sql dba

543


How do I partition a table in sql?

538


is mysql query is case sensitive? : Sql dba

562


What is the cause of mutating table error and how can we solve it?

598