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

Answers were Sorted based on User's Feedback



in account table account type amount ac1 credit 300 ac2 debit 5000 ac3 credit ..

Answer / 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

in account table account type amount ac1 credit 300 ac2 debit 5000 ac3 credit ..

Answer / sanjay

select type,sum(amount)from account table group by type

Is This Answer Correct ?    3 Yes 0 No

in account table account type amount ac1 credit 300 ac2 debit 5000 ac3 credit ..

Answer / kamala k n

select type, sum(amount) over (partiton by sid) from tab

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Oracle General Interview Questions

How to name query output columns in oracle?

0 Answers  


How to convert character types to numeric types?

0 Answers  


what is the difference between data migration and production migration.

0 Answers  


How to return top 5 rows in oracle?

0 Answers  


i want to know about mr.b.kotravel......who has answered for second maxmium salary from employee table

3 Answers  






What is null value in oracle?

0 Answers  


What is difference between SUBSTR and INSTR?

1 Answers  


What is the quickest way to fetch the data from a table?

0 Answers  


dear sir/madam, i have done my engg in 2007 after that i did oracle course (sql,plsql,forms,reports) .from 2008 to 2009 i searched job but didnt got.so i planned to move to sales field & i gone to dubai.till now i m in sales only.now i want to shift my career in to IT industry.but now people are not hiring as fresher.so i planned put fake 1 + exp. is it good or bad or any other way is there to enter in IT.please suggest me or call me 09632087338.

3 Answers  


What are the different windows events activated at runtime ?

0 Answers   Oracle,


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

0 Answers  


What do you mean by redo log file mirroring?

0 Answers  


Categories
  • Oracle General Interview Questions Oracle General (1789)
  • Oracle DBA (Database Administration) Interview Questions Oracle DBA (Database Administration) (261)
  • Oracle Call Interface (OCI) Interview Questions Oracle Call Interface (OCI) (10)
  • Oracle Architecture Interview Questions Oracle Architecture (90)
  • Oracle Security Interview Questions Oracle Security (38)
  • Oracle Forms Reports Interview Questions Oracle Forms Reports (510)
  • Oracle Data Integrator (ODI) Interview Questions Oracle Data Integrator (ODI) (120)
  • Oracle ETL Interview Questions Oracle ETL (15)
  • Oracle RAC Interview Questions Oracle RAC (93)
  • Oracle D2K Interview Questions Oracle D2K (72)
  • Oracle AllOther Interview Questions Oracle AllOther (241)