title: Limit SQL query to only the top two counts per group
body: <p>If I have a DB table called FAVORITE_FLAVOR where each row has a user's favorite flavor of ice cream.</p>
  
  <pre><code>User ID | Flavor      | State
  1       | Chocolate   | CA
  2       | Vanilla     | ND
  3       |   Chocolate | CA
  4       | Rocky Road  | CA
  5       | vanilla     | CA
  6       | Vanilla     | CA
  7       | Vanilla     | CA
  </code></pre>
  
  <p>Now, if I want to query the 2 most popular flavors in each state (normalizing capitalization and whitespace), I could query:</p>
  
  <pre><code>SELECT state, INITCAP(TRIM(flavor)), count(INITCAP(TRIM(flavor))) AS total
  FROM favorite_flavor GROUP BY state, INITCAP(TRIM(flavor))
  ORDER BY state ASC, total DESC;
  </code></pre>
  
  <p>Which returns:</p>
  
  <pre><code>CA | Vanilla    | 3
  CA | Chocolate  | 2
  CA | Rocky Road | 1
  ND | Vanilla    | 1
  </code></pre>
  
  <p>Now, I only wanted to know the top 2 flavors per state. How do I limit the query so that Rocky Road is no longer listed.</p>