Hey guys!
I'm doiing stats for a survey and have a question to ask !
a couple of question there listed as 1 to 5
1-Very Satisfied
2-
3-
4-
5-Very dissatisfied
i record in the DB as follow
Q1a - for question 1 A
and i store either 1,2,3,4 or 5
and so on
so this is my question, what is the best way to query so that it spit out something like
For question 1 A
- 20% picked 1
- 20% picked 2
- 15% picked 3
- 25% picked 4
- 20% picked 5
Would this be good
It works good, but would it be better to do one at a time !Code:SELECT COUNT(tblSurvey.sQ1a) AS numOf,tblSurvey.sQ1a,'Q1a' AS Question FROM tblSurvey GROUP BY tblSurvey.sQ1a UNION ALL SELECT COUNT(tblSurvey.sQ1b) AS numOf,tblSurvey.sQ1b,'Q1b' AS Question FROM tblSurvey GROUP BY tblSurvey.sQ1b UNION ALL SELECT COUNT(tblSurvey.sQ1c) AS numOf,tblSurvey.sQ1c,'Q1c' AS Question FROM tblSurvey GROUP BY tblSurvey.sQ1c UNION ALL SELECT COUNT(tblSurvey.sQ1d) AS numOf,tblSurvey.sQ1d,'Q1d' AS Question FROM tblSurvey GROUP BY tblSurvey.sQ1d
So instead of doiing union all, i would query on at a time, so 4 sql query for the above !
what are your thoughts on this !




Reply With Quote