emerickson
Technical User
I have a SQL table with columns QD1-QD8. I have a query that looks like this:
<CFQUERY name="ShowData" datasource="EdropSQL">
SELECT
SUM(CASE WHEN QD1 = '5' THEN 1 ELSE 0 END) AS StA1,
SUM(CASE WHEN QD1 = '4' THEN 1 ELSE 0 END) AS A1,
SUM(CASE WHEN QD1 = '3' THEN 1 ELSE 0 END) AS SA1,
SUM(CASE WHEN QD1 = '2' THEN 1 ELSE 0 END) AS D1,
SUM(CASE WHEN QD1 = '1' THEN 1 ELSE 0 END) AS SD1,
SUM(CASE WHEN QD1 = '0' THEN 1 ELSE 0 END) AS NA1,
Trainer_UGD, CourseID, CommentsD1
FROM DeliveryEval
</Query>
Then some more queries based on this one, and then the output, which is a table showing how many of each category (StA1, A1, SA1, etc) there are. I could have a query like this one for each QD, but I would rather save myself the typing. Is there any way I could loop this query so that QDx will be increased each time and StAx, Ax, SAx, etc also? And then, will it work with a Loop on the output to show 1 table for each QD?
Thanks,
Eva Erickson
<CFQUERY name="ShowData" datasource="EdropSQL">
SELECT
SUM(CASE WHEN QD1 = '5' THEN 1 ELSE 0 END) AS StA1,
SUM(CASE WHEN QD1 = '4' THEN 1 ELSE 0 END) AS A1,
SUM(CASE WHEN QD1 = '3' THEN 1 ELSE 0 END) AS SA1,
SUM(CASE WHEN QD1 = '2' THEN 1 ELSE 0 END) AS D1,
SUM(CASE WHEN QD1 = '1' THEN 1 ELSE 0 END) AS SD1,
SUM(CASE WHEN QD1 = '0' THEN 1 ELSE 0 END) AS NA1,
Trainer_UGD, CourseID, CommentsD1
FROM DeliveryEval
</Query>
Then some more queries based on this one, and then the output, which is a table showing how many of each category (StA1, A1, SA1, etc) there are. I could have a query like this one for each QD, but I would rather save myself the typing. Is there any way I could loop this query so that QDx will be increased each time and StAx, Ax, SAx, etc also? And then, will it work with a Loop on the output to show 1 table for each QD?
Thanks,
Eva Erickson