title: SQL Query to COUNT fields that match a certain value across all rows in a table
body: <p>I am trying (and failing) to craft a simple SQL query (for SQL Server 2012) that counts the number of occurrences of a value for a given date range.</p>
  
  <p>This is a collection of results from a survey.</p>
  
  <p>So the end result would show there are only 3 lots of values matching '2' and 
  6 values matching '1'.</p>
  
  <p>Even better if the final result could return 3 values:</p>
  
  <pre><code>MatchZero = 62
  MatchOne = 6
  MatchTwo = 3
  </code></pre>
  
  <p>Something Like (I know this is horribly out):</p>
  
  <pre><code>SELECT 
    COUNT(0) AS MatchZero, 
    COUNT(1) AS MatchOne, 
    COUNT(2) As MatchTwo 
  WHERE dated BETWEEN '2014-01-01' AND '2014-02-01'
  </code></pre>
  
  <p>I don't need it grouped by date or anything, simply a total value for each. </p>
  
  <p>Any insights would be greatly received.</p>
  
  <pre><code>+------------+----------+--------------+-------------+------+-----------+------------+
  | QuestionId | friendly | professional | comfortable | rate | recommend |   dated    |
  +------------+----------+--------------+-------------+------+-----------+------------+
  |          3 |        0 |            0 |           0 |    0 |         0 | 2014-02-12 |
  |          9 |        0 |            0 |           0 |    0 |         0 | 2014-02-12 |
  |         14 |        0 |            0 |           0 |    2 |         0 | 2014-02-13 |
  |         15 |        0 |            0 |           0 |    0 |         0 | 2014-01-06 |
  |         19 |        0 |            1 |           2 |    0 |         0 | 2014-01-01 |
  |         20 |        0 |            0 |           0 |    0 |         0 | 2013-12-01 |
  |         21 |        0 |            1 |           0 |    0 |         0 | 2014-01-01 |
  |         22 |        0 |            1 |           0 |    0 |         0 | 2014-01-01 |
  |         23 |        0 |            0 |           0 |    0 |         0 | 2014-01-24 |
  |         27 |        0 |            0 |           0 |    0 |         0 | 2014-01-31 |
  |         30 |        0 |            1 |           2 |    0 |         0 | 2014-01-27 |
  |         31 |        0 |            0 |           0 |    0 |         0 | 2014-01-11 |
  |         36 |        0 |            0 |           0 |    1 |         1 | 2014-01-22 |
  +------------+----------+--------------+-------------+------+-----------+------------+
  </code></pre>