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 / apoorva garg
select count(decode(trim(transaction_type),'D',1)) total_debits,
count(decode(trim(transaction_type),'C',1)) total_credits,
sum(decode(trim(transaction_type),'D',transaction_amount)) total_debits_amt,
sum(decode(trim(transaction_type),'C',transaction_amount)) total_credits_amt
from transaction
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
how many groups of data types? : Sql dba
What is the use of pl/sql table?
What is set serveroutput on in pl sql?
How do you clear the screen in sql?
What is foreign key sql?
Is sql a backend language?
What is a full join sql?
How do I remove sql plus from windows 10?
What is an intersect?
Which is better stored procedure or query?
where are cookies actually stored on the hard disk? : Sql dba
Cite the differences between execution of triggers and stored procedures?
Why do we need databases?
how many columns can be used for creating index? : Sql dba
Why cross join is used?