Pretty simple question - can we run something like the following in sql, if not what's an alternative :

Edit #1 fixed question

The following query should answer : Give me all names and salaries by month for folks whose salary is greater than average of all salaries(not greater than avg. salary by month)

Select name, month, salary
From table
Group by 1,2
Having sum(salary) > avg(salary)