Need help with sql query
I would love some assistance with a sql query against the checkbox database.
What I am trying to do is output a report via the backend database of all the active survey names and the text of their questions, and the question type.
I am going nuts trying to figure this out and it seems to me that someone else may already have one or more queries that would work.
The following Query will give me the QuestionIDs and the Survey Names, but getting the question text is eluding me.
SELECT app_survey.ckbx_Item.ItemID, app_survey.ckbx_Item.ItemTypeID, app_survey.ckbx_ItemType.ItemName,
app_survey.ckbx_ItemType_Categories.CategoryName, app_survey.ckbx_FormsAndFoldersView.ItemName AS SurveyName,
app_survey.ckbx_FormsAndFoldersView.IsActive, app_survey.ckbx_FormsAndFoldersView.ResponseCount,
app_survey.ckbx_FormsAndFoldersView.Owner, app_survey.ckbx_FormsAndFoldersView.DateCreated,
app_survey.ckbx_Template_Items.TemplateID AS SurveyID
FROM app_survey.ckbx_Item INNER JOIN
app_survey.ckbx_ItemType ON app_survey.ckbx_Item.ItemTypeID = app_survey.ckbx_ItemType.ItemTypeID INNER JOIN
app_survey.ckbx_ItemType_Categories ON app_survey.ckbx_ItemType.CategoryID = app_survey.ckbx_ItemType_Categories.CategoryID INNER JOIN
app_survey.ckbx_Template_Items ON app_survey.ckbx_Item.ItemID = app_survey.ckbx_Template_Items.ItemID INNER JOIN
app_survey.ckbx_FormsAndFoldersView ON app_survey.ckbx_Template_Items.TemplateID = app_survey.ckbx_FormsAndFoldersView.ItemID
WHERE (app_survey.ckbx_ItemType.CategoryID = 1000) AND (app_survey.ckbx_FormsAndFoldersView.ItemType = 'Form') AND
(app_survey.ckbx_FormsAndFoldersView.IsActive = 1)
Thank you for your time and assistance,
Bonnie
|