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 / deepak mohanty

SELECT SUM(decode(txn_typ,'D',1)) "Total Debit
Count",SUM(decode(txn_typ,'C',1)) "Total Credit Count",
SUM(decode(txn_typ,'D',txn_amt)) "Total Debit
Amount",SUM(decode(txn_typ,'C',txn_amt)) "Total Credit Amount"
from txn_tab

Is This Answer Correct ?    13 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why use subqueries instead of joins?

605


How does a self join work?

516


What is a table?

565


Define select, insert, create, delete, update, drop keywords

598


How can we avoid duplicating records in a query?

562






Any attempt to navigate programmatically to disabled form in a call_form stack is allowed?

578


How do I run a query in pl sql developer?

560


What is synchronized subquery?

595


What is synonyms?

570


What is an escape character in sql?

562


How do you clear the screen in sql?

599


what is sub-query? : Transact sql

596


What is meant by <> in sql?

503


What are the sql aggregate functions?

604


Can pl sql procedure have a return statement?

548