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 db journal file?

520


what are all the different normalizations? : Sql dba

509


What is an example of translating a date into julian format?

580


What company owns postgresql?

560


Is it possible to link two groups inside a cross products after the cross products group has been created?

595






What is a temporal data type?

597


What is sql constant?

507


What is compute?

560


What are all the ddl commands?

628


What is the purpose of design view?

525


How many disk partitions should I have?

551


What does pl sql developer do?

510


How do temporal tables work?

519


What pl/sql package consists of?

638


What is sql stand for?

575