title: Select the first row of a column in a group of rows within another column
body: <p>I have to display a list of the first row of a column within a group of rows within another column</p>
  <p><strong>Basic Query:</strong></p>
  <blockquote>
  <p>SELECT *  FROM Table_Example cxp</p>
  </blockquote>
  <p><strong>My Table</strong></p>
  <pre><code>    |plan   |code   |des   |month   |
  ----+-------+-------+------+--------+
      | 150B  | Alpha | etc.a| 1      |
  ----+-------+-------+------+--------+
      | 150B  | Beta  | etc.b| 2      |
  ----+-------+-------+------+--------+
      | 2600C | Alpha | etc.a| 6      |
  ----+-------+-------+------+--------+
      | 2600C | Alpha | etc.a| 7      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 3      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 7      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 9      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 2      |
  ----+-------+-------+------+--------+
      | 2600C | Gama  | etc.c| 4      |
  ----+-------+-------+------+--------+
      | 2600C | Gama  | etc.c| 12     |
  ----+-------+-------+------+--------+
      | 2600C | Delta | etc.d| 22     |
  ----+-------+-------+------+--------+
      | 42F   | Alpha | etc.a| 15     |
  </code></pre>
  <p><strong>Expected Result</strong></p>
  <pre><code>    |plan   |code   |des   |month   |
  ----+-------+-------+------+--------+
      | 2600C | Alpha | etc.a| 6      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 3      |
  ----+-------+-------+------+--------+
      | 2600C | Gama  | etc.g| 4      |
  ----+-------+-------+------+--------+
      | 2600C | Delta | etc.d| 22     |
  ----+-------+-------+------+--------+
  </code></pre>
  <p><strong>Transcript Result:</strong> Having the variable '@plan', only show the rows that match that value (example: if '@plan' is 2600C) and within that group of rows, only show the first row of each different 'code' value</p>
  <p><strong>What i tried to do</strong></p>
  <blockquote>
  <p>SELECT * FROM Table_Example cxp  WHERE plan = '2600C'</p>
  </blockquote>
  <pre><code>    |plan   |code   |des   |month   |
  ----+-------+-------+------+--------+
      | 2600C | Alpha | etc.a| 6      |
  ----+-------+-------+------+--------+
      | 2600C | Alpha | etc.a| 7      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 3      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 7      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 9      |
  ----+-------+-------+------+--------+
      | 2600C | Beta  | etc.b| 2      |
  ----+-------+-------+------+--------+
      | 2600C | Gama  | etc.c| 4      |
  ----+-------+-------+------+--------+
      | 2600C | Gama  | etc.c| 12     |
  ----+-------+-------+------+--------+
      | 2600C | Delta | etc.d| 22     |
  </code></pre>
  <p><em>But i can't get only the first row of each different 'code'
  I was thinking in a SubQuery but i tried a lot of them and i cant get the correct result
  or it returns only the 'code' column without the other columns like:</em></p>
  <pre><code>|code   |
  +-------+
  | Alpha |     
  +-------+
  | Beta  |       
  +-------+
  | Gama  |      
  +-------+
  | Delta |      
  +-------+
  </code></pre>