I have a bunch of queries set up with outer joins so that they should return all records from one table and only matching records from another table. The problem is, they aren't all working as they are supposed to be (and oddly, some of them are). Here is the SQL statement I'm using and the only thing that changes for each query is the joined field in the secondary table (in this case "Lodging").
I have been trying to research it some, and my SQL skills are very minimal, so I'm at a loss. I have seen suggestions to use UNION statements but when I try to implement it in this SQL I get error messages about "RatingValue" not being part of an aggregate function...
Any help is greatly appreciated.
SELECT tblEvalRatings.RatingValue, tblEval_Participants.Lodging, Count(tblEval_Participants.Lodging) AS CountOfLodging, tblEval_Participants.TrgCode, tblEvalRatings.Question
FROM tblEvalRatings LEFT JOIN tblEval_Participants ON tblEvalRatings.RatingValue = tblEval_Participants.Lodging
GROUP BY tblEvalRatings.RatingValue, tblEval_Participants.Lodging, tblEval_Participants.TrgCode, tblEvalRatings.Question, tblEvalRatings.RatingSequence
HAVING (((tblEval_Participants.TrgCode)=[Forms]![frmEvalGuide].[trgcode]) AND ((tblEvalRatings.Question) Like "*lodging*") AND ((tblEvalRatings.RatingSequence)>0)) OR (((tblEval_Participants.TrgCode) Is Null) AND ((tblEvalRatings.Question) Like "*lodging*") AND ((tblEvalRatings.RatingSequence)>0))
ORDER BY tblEvalRatings.RatingSequence;
I should also add that the Outer Join seems to be working fine when I remove all criteria from the query design (fine is not that it gives me the results that I need, but it does return all records from one table and matching from another, just doesn't work when I set the criteria I need)...
I have been trying to research it some, and my SQL skills are very minimal, so I'm at a loss. I have seen suggestions to use UNION statements but when I try to implement it in this SQL I get error messages about "RatingValue" not being part of an aggregate function...
Any help is greatly appreciated.
SELECT tblEvalRatings.RatingValue, tblEval_Participants.Lodging, Count(tblEval_Participants.Lodging) AS CountOfLodging, tblEval_Participants.TrgCode, tblEvalRatings.Question
FROM tblEvalRatings LEFT JOIN tblEval_Participants ON tblEvalRatings.RatingValue = tblEval_Participants.Lodging
GROUP BY tblEvalRatings.RatingValue, tblEval_Participants.Lodging, tblEval_Participants.TrgCode, tblEvalRatings.Question, tblEvalRatings.RatingSequence
HAVING (((tblEval_Participants.TrgCode)=[Forms]![frmEvalGuide].[trgcode]) AND ((tblEvalRatings.Question) Like "*lodging*") AND ((tblEvalRatings.RatingSequence)>0)) OR (((tblEval_Participants.TrgCode) Is Null) AND ((tblEvalRatings.Question) Like "*lodging*") AND ((tblEvalRatings.RatingSequence)>0))
ORDER BY tblEvalRatings.RatingSequence;
I should also add that the Outer Join seems to be working fine when I remove all criteria from the query design (fine is not that it gives me the results that I need, but it does return all records from one table and matching from another, just doesn't work when I set the criteria I need)...
Last edited: