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
interview questions with answer for cts
How to sort the query output in oracle?
What are the common oracle dba tasks?
Which are the five query types available in oracle?
When system tablespace is created?
How to save query output to a local file?
What is the difference between alert log file and tarce file ?
How to set up autotrace for a user account?
How can I combine multiple rows into a comma-delimited list in oracle?
What is materialized view in Oracle?
How to connect to oracle using service name instead of sid?
What is open database communication (odbc) in oracle?
Does oracle partitioning improve performance?
Point out the difference between user tables and data dictionary?
What are the advantages of oracle?