G
Guest
Hiya
I have a report based on an SQL query (lets say SQL1). Within the report I have a chart based on another SQL query (lets say SQL2). However SQL2 is based solely on SQL1
I can't get SQL2 to all be referenced in SQL without referring to SQL1 as a saved query. I want SQL1 to be built through code, hence do not want it to be a saved query
Can anyone help me (or tell me if it is possible) to incorporate the code of SQL1 into SQL2 without referencing SQL1 as a saved query
Here is the code for SQL1
SELECT tblQuestions.SectnID, tblSections.SectnText, tblQuestions.QstnID, IIf([QstnLvl2] Is Null,[QstnLvl1],[QstnLvl1] & " " & [QstnLvl2] & ")") AS QstnNo, tblQuestions.QstnText, tblResponsesList.RspnsVal, qryStatResponses.StatRspns, Count(qryStatResponses.StatRspns) AS CountOfStatRspn
FROM tblSections INNER JOIN ((tblQuestions INNER JOIN qryStatResponses ON tblQuestions.QstnID = qryStatResponses.QstnID) INNER JOIN tblResponsesList ON (qryStatResponses.QstnID = tblResponsesList.QstnID) AND (qryStatResponses.StatRspns = tblResponsesList.Rspns)) ON tblSections.SectnID = tblQuestions.SectnI
GROUP BY tblQuestions.SectnID, tblSections.SectnText, tblQuestions.QstnID, IIf([QstnLvl2] Is Null,[QstnLvl1],[QstnLvl1] & " " & [QstnLvl2] & ")"), tblQuestions.QstnText, tblResponsesList.RspnsVal, qryStatResponses.StatRspns
Here is the code for SQL2
SELECT SQL1.StatRspns, SQL1.CountOfStatRspns FROM SQL1 GROUP BY SQL1.StatRspns, SQL1.CountOfStatRspns, SQL1.RspnsVal ORDER BY SQL1.RspnsVal DESC
Thanks so much for any advice
Basil
I have a report based on an SQL query (lets say SQL1). Within the report I have a chart based on another SQL query (lets say SQL2). However SQL2 is based solely on SQL1
I can't get SQL2 to all be referenced in SQL without referring to SQL1 as a saved query. I want SQL1 to be built through code, hence do not want it to be a saved query
Can anyone help me (or tell me if it is possible) to incorporate the code of SQL1 into SQL2 without referencing SQL1 as a saved query
Here is the code for SQL1
SELECT tblQuestions.SectnID, tblSections.SectnText, tblQuestions.QstnID, IIf([QstnLvl2] Is Null,[QstnLvl1],[QstnLvl1] & " " & [QstnLvl2] & ")") AS QstnNo, tblQuestions.QstnText, tblResponsesList.RspnsVal, qryStatResponses.StatRspns, Count(qryStatResponses.StatRspns) AS CountOfStatRspn
FROM tblSections INNER JOIN ((tblQuestions INNER JOIN qryStatResponses ON tblQuestions.QstnID = qryStatResponses.QstnID) INNER JOIN tblResponsesList ON (qryStatResponses.QstnID = tblResponsesList.QstnID) AND (qryStatResponses.StatRspns = tblResponsesList.Rspns)) ON tblSections.SectnID = tblQuestions.SectnI
GROUP BY tblQuestions.SectnID, tblSections.SectnText, tblQuestions.QstnID, IIf([QstnLvl2] Is Null,[QstnLvl1],[QstnLvl1] & " " & [QstnLvl2] & ")"), tblQuestions.QstnText, tblResponsesList.RspnsVal, qryStatResponses.StatRspns
Here is the code for SQL2
SELECT SQL1.StatRspns, SQL1.CountOfStatRspns FROM SQL1 GROUP BY SQL1.StatRspns, SQL1.CountOfStatRspns, SQL1.RspnsVal ORDER BY SQL1.RspnsVal DESC
Thanks so much for any advice
Basil