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
Write a sql query to find the names of employees that begin with ‘a’?
What is the use of desc in sql?
Can we use rowid as primary key?
Does sql profiler affect performance?
write an sql query to find names of employee start with 'a'? : Sql dba
Can a varchar be a primary key?
how to create a table index in mysql? : Sql dba
Do ddl statements need commit?
What is a system versioned table?
What can you do with pl sql?
What is difference between stored procedures and application procedures?
Mention what is the plv (pl/vision) package offers?
How do I find duplicates in a single column in sql?
What is execute immediate?
how to rename an existing column in a table? : Sql dba