I have a query similar to the following:
SELECT
users.id FROM users LEFT JOIN sales ON installations.customer = users.id
What I would like to say is something like “WHERE count(sales.id) > 4” – meaning that if the user has more than 4 sales assoc with them. I am not sure if I am going about this the wrong way or not though
This will group all of the sales by user, then return only those sales that have more than four records in the
salestable.I didn’t duplicate your join condition from above because it didn’t seem to make much sense, as it’s referencing tables that aren’t in your query anywhere.