Reputation: 115
how to get customer ids whose average purchase is more than 50 rupees (col.3 is purchase id and has to be aggregated per customer)
SELECT distinct customer id from table where average purchase of a customer is greater than 50 group by customer id
Upvotes: 0
Views: 36
Reputation: 37473
You can try the below -
SELECT customer_id
from table
group by customer_id
having avg(col2)>50
Upvotes: 2