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
What is PL/SQL Records?
Explain spool.
Which table is left in left join?
How to get list of all tables from a database?
Does sql profiler affect performance?
Can we use pl sql in mysql?
How run sql*plus commands that are stored in a local file?
Describe types of sql statements?
What is compute?
What is embedded sql in db2?
What is a subquery in sql?
What is on delete set null?
Why indexing is needed?
What is a crud api?
Is null operator in sql?