title: How to select top 10% of values in SQL
body: <p>I know it's possible to select the maximum value in SQL with MAX(), but if I have a table with two columns, an ID and a value, is it possible to select the top 10% of values for each ID. There is not a set number of values for each ID.</p>
  
  <p>EDIT: Apologies for not being clearer,
  I'm working with Microsoft SQL server Managment studio. Table A looks like:</p>
  
  <pre><code>ID,     Value
  112345, 1
  112345, 2
  112345, 3
  112345, 2
  112345, 3
  112345, 18
  112345, 32
  112357, 10
  112346, 15
  112346, 16
  </code></pre>
  
  <p>If it were to select the top 50% for each I would want the select to produce:</p>
  
  <pre><code>ID,     Value
  112345, 3
  112345, 3
  112345, 18
  112345, 32
  112357, 10
  112346, 16
  </code></pre>
  
  <p>I would prefer if the number of returned rows was rounded up, eg. 10% of an ID that had 4 rows would still return 1 value</p>