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

What is PL/SQL Records?

644


Explain spool.

707


Which table is left in left join?

551


How to get list of all tables from a database?

647


Does sql profiler affect performance?

568






Can we use pl sql in mysql?

529


How run sql*plus commands that are stored in a local file?

532


Describe types of sql statements?

556


What is compute?

570


What is embedded sql in db2?

517


What is a subquery in sql?

521


What is on delete set null?

578


Why indexing is needed?

530


What is a crud api?

508


Is null operator in sql?

621