-
select query problem
Hi,
I have to produce statistics based on the results of a questionnaire and I need to minimize the number of queries to the database in order to produce the results.
I have 3 columns (each column relates to a particular question) that can contain numeric responses with values 0 thru 5.
I need to be able to determine the total number of times a response (0 thru 5) was given for each column.
I'm hoping to be able to do this in 3 queries at most (one for each question), but less would be better
-
3 query method:
Select Column1, count(Column1)
From TheTable
Group By Column1
Order By Column1
Then repeat same query for column 2 and 3.
The one drawback is that it does not return instances where there are 0 entries.
For example, if the answers given were 1 five times, 2 four times, 3 three times, 4 two times, and 5 zero times, then the results would look like:
1, 5
2, 4
3, 3
4, 2
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|