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

How do I run pl sql in sql developer?

855


What is pl sql block in dbms?

706


What is difference between inner join and self join?

776


describe transaction-safe table types in mysql : sql dba

701


Can we have two clustered index on a table?

760






Which are sql * plus commands?

714


What are triggers and its types?

753


Can we insert data into materialized view?

708


What is %type in sql?

691


What is meant by user defined function?

761


How exception is different from error?

762


how many groups of data types? : Sql dba

725


How does postgresql compare to "nosql"?

767


Does mysql_real_escape_string prevent sql injection?

689


Is natural join same as inner join?

677