I'm trying to count all records from my 'jobs' table that have a 'completed' status, excluding any jobs that are either 'fix-it' or 'vacancy' job types. This is what I'm using, but I'm not sure if this is giving me the correct results:
SELECT id, client_id, COUNT(*) AS count FROM jobs
WHERE jobType != 'fix-it' AND jobType != 'vacancy' AND status = 'completed'
GROUP by jobs.client_id
I then look at the result to see if I have two or more completed jobs under a given client.
Does this look correct?
NULL != colevaluates to NULL, not true or false. Re: "id", it's not just not needed, it doesn't make sense, and I'd recommend using ONLY_FULL_GROUP_BY.