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


Please Help Members By Posting Answers For Below Questions

How to update values in a table in oracle?

579


What is truncate oracle?

535


What is the difference between online and offline backups?

562


Difference between hot backup vs. Cold backup?

606


Where are the settings stored for each instance in oracle?

630






What privilege is needed for a user to delete rows from tables in another schema?

564


How do I spool in oracle?

545


State and explain about oracle instance?

551


What privilege is needed for a user to connect to oracle server?

561


What do you understand by database schema and what does it hold?

598


What is the order of defining local variables and sub procedures/functions?

602


How to write an inner join with the where clause in oracle?

586


Explain what are the different type of segments?

580


Explain the difference between replace() and translate() functions in oracle?

582


hi friends i completed b.com 2004.i have 3y accounting exp. in manufacturing company.now i have completed oracle finance.pls suggest me how will get job in oracle.can i get job in oracle.

1965