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
  • 43,011
  • 8
  • 105
  • 200

4 Answers4

2

A standard SQL aggregate

SELECT Answer, COUNT(*) FROM MyTable GROUP BY Answer
gbn
  • 422,506
  • 82
  • 585
  • 676
2
Select Answer, Count(*) FROM answer GROUP BY Answer
Flo
  • 1,660
  • 4
  • 21
  • 34
2
SELECT answer,COUNT(*) FROM table
GROUP BY answer
Tim Sparg
  • 3,294
  • 2
  • 27
  • 40
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
  • 128,221
  • 31
  • 203
  • 222