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
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 |
Answer / sanjay
select type,sum(amount)from account table group by type
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / kamala k n
select type, sum(amount) over (partiton by sid) from tab
| Is This Answer Correct ? | 0 Yes | 0 No |
How to increment dates by 1 in oracle?
What is meant by recursive hints ?
What is a subquery?
src name sex a,male b,female c,male d,female Required output : male female a,b c,d tried pivot but was not successfull select * from src pivot (max(name) for sex in ('MALE','FEMALE'));
What are the ansi data types supported in oracle?
what are the advantages of running a database in NO archive log mode?
What is redo log?
Define oracle database
What is a recycle bin in oracle?
What is private procedure oracle?
How to drop an existing view in oracle?
Oracle
0 Answers ABC, Genpact, HUI, Oracle,