oracle - Sum for same ID in every row SQL -


i having table below..

    r_id     marks      1        25      1        25         1        25      2        30      2        30   

now want query in sum of marks each r_id should calculated , result should be

    r_id  marks   sum      1      25    75         1      25    75      1      25    75      2      30    60       2      30    60 

i need in oracle without using pl/sql. please help. have tried using cube, rollup, grouping sets in group by, nothing working.

you want use analytic functions this. these functions use over clause:

select r_id, marks, sum(marks) on (partition r_id) t; 

Comments