title: Select distinct values, and count number of occurrences
body: <p>I have a list of classes and categories for the classes. I would like to display how many classes each category has. Something like this:</p>
  
  <pre><code>category | # of classes
  Sports   | 12
  Fitness  | 32
  Climbing | 8
  </code></pre>
  
  <p>The table is set up so that each class is on a line that includes the category.</p>
  
  <pre><code>category | class_name
  fitness  | Learn to Skate
  </code></pre>
  
  <p>I have the following SQL, which generates a list of distinct categories:</p>
  
  <pre><code>select 
      distinct category
  
  from classes
  
  order by category asc
  
  ; Output:
  ; Fitness
  ; Climbing
  ; Recreation
  ; ...
  </code></pre>
  
  <p>I also want to display <em>how many</em> classes there are. I figured this would be straightforward:</p>
  
  <pre><code>select 
      distinct category,
      count(distinct category)
  
  from classes
  
  order by category asc
  
  ; Output:
  ; Fitness | 11
  </code></pre>
  
  <p>The output almost works, but it only produces one row. Without the <code>count()</code> it produces 11 rows, as expected. Why does this only produce one row? How can I achieve this?</p>