acname actype amount
ac1 credit 300
ac2 credit 4000
ac1 debit 4000
ac2 debit 455
ac1 credit 500
how to get sum of credit and sum of debit for each account

Answers were Sorted based on User's Feedback



acname actype amount ac1 credit 300 ac2 credit 4000 ac1 debit 4000 ac2 debit ..

Answer / terence

select
acname,
sum(decode(actype,'credit',amount,0)) Credit,
sum(decode(actype,'debit',amount,0)) Debit
from account_table
group by acname

Is This Answer Correct ?    11 Yes 1 No

acname actype amount ac1 credit 300 ac2 credit 4000 ac1 debit 4000 ac2 debit ..

Answer / amit kumar

select sum(amount) amt , acname, actype from table group by
acname , actype

Is This Answer Correct ?    6 Yes 2 No

Post New Answer

More Oracle General Interview Questions

How to display row numbers with the records?

0 Answers  


How to enter a new row into a table interactively?

0 Answers  


Difference between hot backup vs. Cold backup?

0 Answers  


Explain what are the different type of segments?

0 Answers  


What is recovery manager in Oracle?

0 Answers   MCN Solutions,






Can multiple cursors being opened at the same time?

0 Answers  


5. Display full details for the creditor/s who has received the single largest payment. Do not use a table join or set operator anywhere in your query.

6 Answers   Wipro,


What are the types of trigger in oracle?

0 Answers  


What is the difference between SQL, DDL, and DML?

7 Answers   BeBo Technologies, Wipro,


Can any one explain me when i execute below query.. select months_between('07-JUL-12','10-FEB-12') from dual; Out put:- 4.90322581 How oracle calculate?

0 Answers  


What happens to the current transaction if a ddl statement is executed?

0 Answers  


What is the difference between formal parameters and actual parameters?

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)