Inner Join fails as select param is not contained in Group By?


#1

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?


#2

May reading a few articles will give you a better knwledge…
Found with google-search
Inner Join fails as select param is not contained in Group By site:stackoverflow
for instance
https://stackoverflow.com/questions/8857090/group-by-using-parameters-in-sql


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.