0

I have a table like this:

--Table Answer--
Id     Question_id  Attendee_id  Answer
100    qst1          001         Name1
101    qst2          001         Name1
102    qst3          002         Name2

I would like to know how I can count the answers that have the same values?

NGLN
  • 41,953
  • 8
  • 104
  • 194

4 Answers4

2

A standard SQL aggregate

SELECT Answer, COUNT(*) FROM MyTable GROUP BY Answer
gbn
  • 408,740
  • 77
  • 567
  • 659
2
Select Answer, Count(*) FROM answer GROUP BY Answer
Flo
  • 1,640
  • 4
  • 21
  • 34
2
SELECT answer,COUNT(*) FROM table
GROUP BY answer
Tim Sparg
  • 3,254
  • 2
  • 26
  • 39
1

For every question?

SELECT
    Question_id,
    Answer,
    COUNT(1) qty
GROUP BY
    Question_id, Answer

Exclude Question_id from SELECT and GROUP BY if you want the total counts, not partitioned by question, although I assume that figure would be less useful.

David Hedlund
  • 125,403
  • 30
  • 199
  • 217