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
Why query optimization is needed?
What are the most important characteristics of pl/sql?
How are functions and procedures called in PL/SQL?
What are the different types of dbmss?
what are all the different normalizations? : Sql dba
What are transaction and its controls?
What is difference between procedure and trigger?
what are dynamic queries in t-sql? : Transact sql
What is pragma in pl sql?
What does sql stand for?
Can we call a function containing dml statements in a select query?
Cite the differences between execution of triggers and stored procedures?
What are different joins used in sql?
What port does sql server use?
How to run pl sql program in mysql?