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 do you delete duplicates in sql query using rowid?
Can we enter data in a table in design view?
what is 'mysqladmin' in mysql? : Sql dba
What is constant in pl sql?
Why truncate is used in sql?
Can we use having without group by in sql?
what is the functionality of the function htmlentities? : Sql dba
What is trigger explain with example?
What is scalar data type in pl sql?
what's the difference between a primary key and a unique key? : Sql dba
What is sqlcommand?
How many sql are there?
What is mutating table error?
What is string data type in sql?
what is 'mysqlimport'? : Sql dba