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 left join is used in sql?

535


How can you create an empty table from an existing table?

606


how to write date and time literals? : Sql dba

546


Why do we use cursors?

524


Does a join table need a primary key?

543






how to include comments in sql statements? : Sql dba

558


What are the benefits of stored procedures?

545


What is sql*plus?

581


Which join is default?

534


What schema means?

537


What is the difference between having clause and where clause?

583


Can a composite key be null?

538


What is the maximum number of rows in sql table?

559


What is the use of count (*) in sql?

561


what is oltp (online transaction processing)? : Sql dba

545