Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

What is group by in sql?

0 Answers  


What is restrict in sql?

0 Answers  


what is Difference between Having and Where clause?

5 Answers   IBM,


Can we commit in trigger?

0 Answers  


Can you have more than one key in a database?

0 Answers  


What is an inconsistent dependency?

0 Answers  


What is the difference between rename and alias?

0 Answers  


How to create a menu in sqlplus or pl/sql?

0 Answers  


What is clustered, non-clustured and unique index. How many indexes can be created on a table ?

3 Answers   TCS,


what are set operators in sql? : Sql dba

0 Answers  


what are the advantages and disadvantages of cascading style sheets? : Sql dba

0 Answers  


What is sql query limit?

0 Answers  


Categories