How to select from tableA sum of grouped numbers from tableB above their sums average in Oracle?
- by Nazgulled
I have data like this:
tableA.ID
---------
1
2
3
tableB.ID tableB.NUM
--------------------
1 10
1 15
2 18
3 12
2 15
3 13
1 12
I need to select tableA IDs where the sum of their NUMs in tableB is above the average of all tableA IDs sums. In other words:
SUM ID=1 -> 10+15+12 = 37
SUM…