Here are my two queries that I want to convert to VBA SQL code:
Query1: SELECT tblRatings.RatingSessionID, tblRatings.SupplierID,
tblSuppliers.SupplierName, tblRatings.UserName, Sum(([Rating]*[Weight]))
AS Score, Sum((10*[Weight])) AS MaxScore,
Format([Score]/[MaxScore],'Fixed') AS [Score %]
FROM tblSuppliers INNER JOIN (tblCriteria RIGHT JOIN tblRatings ON
tblCriteria.CriteriaNumber = tblRatings.CriteriaNumber) ON
tblSuppliers.SupplierID = tblRatings.SupplierID
GROUP BY tblRatings.RatingSessionID, tblRatings.SupplierID,
tblSuppliers.SupplierName, tblRatings.UserName
HAVING (((Count(tblRatings.Rating))=51));
Query2: SELECT qryCompletedSurveyScores.RatingSessionID,
qryCompletedSurveyScores.SupplierID,
qryCompletedSurveyScores.SupplierName,
Avg(qryCompletedSurveyScores.Score) AS ScoreAvg,
Last(qryCompletedSurveyScores.MaxScore) AS MS,
Format([ScoreAvg]/[MS],'Fixed') AS [Score %],
Count(qryCompletedSurveyScores.Score) AS SC
FROM qryCompletedSurveyScores
GROUP BY qryCompletedSurveyScores.RatingSessionID,
qryCompletedSurveyScores.SupplierID, qryCompletedSurveyScores.SupplierName
HAVING (((qryCompletedSurveyScores.RatingSessionID) Like "*"))
ORDER BY Avg(qryCompletedSurveyScores.Score) DESC;
When I try to put query1's sql into query2's FROM clause I get "error in
FROM clause". Can this be done?
Dan
Disagree Yes and Probably.
It depends on the naming scheme of the fields. Since the OP didn't give us any
details, on his query structures, I guess he/she is free to experiment.