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
Define SQL and state the differences between SQL and other conventional programming Languages?
What is difference between db2 and sql?
Are stored procedures faster than dynamic sql?
what is the command line end user interface - mysql? : Sql dba
Can 2 queries be executed simultaneously in a distributed database system?
When to use inner join and left join?
Write a sql query to convert all character to uppercase after hypen.
hi,i plan to put experience on PLSQL ,can anyone suggest me for any institutes in bangalore or how to prepare for interviews
What is the difference between inner join and outer join?
What is the usage of distinct keyword?
What are the different types of constraints?
explain about mysql and its features. : Sql dba
How do I partition a table in sql?
is mysql query is case sensitive? : Sql dba
What is the cause of mutating table error and how can we solve it?