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
State all possible different index configurations a table can possibly have?
How to pass a parameter to a cursor in oracle?
Point out the difference between user tables and data dictionary?
Will you be able to store pictures in the database?
Can we call procedure inside function in oracle?
Explain a data segment?
How do I limit the number of rows returned by an oracle query after ordering?
What are a cluster and non-cluster index?
How to set up autotrace for a user account?
Define oracle database
How to start an oracle instance?
How to retrieve values from data fields in record variables?
What do you understand by a database object?
How do we create privileges in oracle?
ABOUT IDENTITY?