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
Why left join is used in sql?
How can you create an empty table from an existing table?
how to write date and time literals? : Sql dba
Why do we use cursors?
Does a join table need a primary key?
how to include comments in sql statements? : Sql dba
What are the benefits of stored procedures?
What is sql*plus?
Which join is default?
What schema means?
What is the difference between having clause and where clause?
Can a composite key be null?
What is the maximum number of rows in sql table?
What is the use of count (*) in sql?
what is oltp (online transaction processing)? : Sql dba