trans_id trans_date trans_amt debit_credit_indicator
001 01-JAN-13 1099 cr
001 12-JAN-13 500 db
002 24-FEB-13 400 db
002 23-MAR-13 345 cr
001 18-APR-13 800 cr
002 15-MAR-13 600 db
001 12-FEB-13 200 cr

i want like this output
trans_id trans_date trans_amt debit_credit_indicator
001 JAN 1599 cr

no.of trans
2

i want trans_id and trans_date like 'JAN' or 'FEB' etc,
trans_amt i want all credit amount - debit amount per each
trans_id. and debit_credit_indicator and no.of transactions
in a month.



trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr ..

Answer / vinay

Select distinct trans_id ,
to_char(trans_date,'MON') as TRANS_DATE,
count(trans_amt) over (partition by trans_id,to_char
(trans_date,'MON')) as No_OF_TRANSACTION
,sum(trans_amt) over (partition by trans_id,to_char
(trans_date,'MON')) as TRANS_AMOUNT,
debit_credit_indicator from CUSTOMER

Is This Answer Correct ?    3 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Is it possible to pass parameters to triggers?

0 Answers  


package specification-3 procedures package body-2 procedures will is execute

2 Answers   PWC,


Is it possible to include an insert statement on the same table to which the trigger is assigned?

0 Answers  


Does asenumerable execute the query?

0 Answers  


i want count no of values in a column i.e enam eempno phoneno x 1 (98765,09887,096561,87964579,156678,678900876) that means if i select phone no from table i want to get total count of phone numbers i.e 6

8 Answers   Satyam,






What's the procedure?

0 Answers  


What is the difference between left join and left outer join?

1 Answers  


What are sql procedures?

0 Answers  


What is Referential Integrity?

3 Answers   IBM,


what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba

0 Answers  


where are cookies actually stored on the hard disk? : Sql dba

0 Answers  


Can we change the table name in sql?

0 Answers  


Categories