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
How do I run pl sql in sql developer?
What is pl sql block in dbms?
What is difference between inner join and self join?
describe transaction-safe table types in mysql : sql dba
Can we have two clustered index on a table?
Which are sql * plus commands?
What are triggers and its types?
Can we insert data into materialized view?
What is %type in sql?
What is meant by user defined function?
How exception is different from error?
how many groups of data types? : Sql dba
How does postgresql compare to "nosql"?
Does mysql_real_escape_string prevent sql injection?
Is natural join same as inner join?