title: Returning distinct results for each value combination
body: <p>I'm trying to return a random ID for each year and code combination that is used. The database is quite large, so i'm trying to get a random sample for testing and need to make sure each year and code is represented.</p>
  <p>A fair example would be to assume there's over a hundred ID's for every combination, but the year and code are limited. I'm hoping to get a result that would look like the following</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>YEAR</th>
  <th>CODE</th>
  <th>ID</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>2015</td>
  <td>CODE_A</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2015</td>
  <td>CODE_B</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2015</td>
  <td>CODE_C</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2015</td>
  <td>CODE_D</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2015</td>
  <td>CODE_E</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2016</td>
  <td>CODE_A</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2016</td>
  <td>CODE_B</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2016</td>
  <td>CODE_C</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2016</td>
  <td>CODE_D</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  <tr>
  <td>2016</td>
  <td>CODE_E</td>
  <td>-RANDOM ID FOR THIS YEAR/CODE COMBINATION</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>..etc. For all year/code combinations. I'm currently using:</p>
  <pre><code>select year, code, id from 
    (
    select * 
    from table1
    order by dbms_random.value
    )
  where rownum &lt;= 25
  order by year;
  </code></pre>
  <p>This will get me 25 random parcels, but it's not guaranteed to represent every year/code combination. I've searched where I could and I apologize if I missed something obvious. I may not have searched correctly. Any help or pointers in the right direction would be greatly appreciated.</p>