I am trying to run an inner join with a case query. This is what I have so far:
SELECT jobs.ID, SUM(CASE WHEN jobresponses.result = 'true' THEN 1 ELSE 0 END) as True, SUM(CASE WHEN jobresponses.result = 'false' THEN 1 ELSE 0 END) as False FROM jobresponses JOIN jobs on jobresponses.jobId = job.ID GROUP BY jobs.ID
This works fine, however if I add
jobs.title to the select parameters, I get the error:
Column ‘jobs.title’ is invalid in the select list because it is not contained in either an aggregate function or a GROUP BY clause.
Have I miss understood something? What am I doing wrong?