I need to select data at different granular level (in Oracle). I have a table with data as:
c1 c2 c3 c4
a a1 10 5
a a2 10 5
b b1 10 5
b b2 10 5
I need to write a query that would return data as:
c1 c2 c3
a 20 10 --aggregated data
a1 10 5 --lowest granular level data
a2 10 5 --lowest granular level data
b 20 10
b1 10 5 -- data of b1, b2 should follow the data of b; likewise a1, a2 should follow data of a
b2 10 5
I find this quite unusual because I need to select data at both lowest granular level and an aggregated level. How can I do this?
You may start from this:
To get only your groups you need
see here another examples and explanations.