in account table
account type amount
ac1 credit 300
ac2 debit 5000
ac3 credit 3000
ac1 debit 4000
ac3 debit 2000
ac2 credit 4000
write a query how to get sum of credit & sum of debit
Answer Posted / vijay patil
-----------table lavel credit debit
select
sum(case when type=credit then isnull(amount,0)end)sum_credit,
sum(case when type=debit then isnull(amount,0) end)sum_debit
from account_table;
OR -----------table lavel credit debit
select type,sum(amount)amt
from account_table
group by type;
OR (at accont lavel credit debit)
select account,type,sum(amount)amt
from account_table
group by account,type;
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
What is an oracle and why it is used?
What is the relationship among database, tablespace and data file?
What is the difference between I and G in Oracle?
What is a select query statement in oracle?
Give the various rollback segment states.
Will you be able to store pictures in the database?explain.
What is the difference between "as" and "is" in an oracle stored procedure?
What is oracle data type?
How to turn on or off recycle bin for the instance?
How can you use check constraints for self referential integrity?
What are the database administrators utilities available?
What are the four Oracle system processes that must always be up and running for the database to be useable?
How many categories of data types?
What is materialized view in Oracle?
What is set operator oracle?