title: MySQL- Select at least n rows per group
body: <p>Suppose you have </p>
  
  <pre><code>id   /   value
  1        2
  1        3
  1        6
  2        3
  3        1 
  3        3
  3        6
  </code></pre>
  
  <p>And I want to retrieve at least n rows per id group, let's say n = 4. In addition, it would help if a counter is added as a column. So the results should be like:</p>
  
  <pre><code>counter /  id   /  value
  1          1       2
  2          1       3
  3          1       6
  4          null    null
  1          2       3
  2          null    null
  3          null    null
  4          null    null
  1          3       1
  2          3       3
  3          3       6
  4          null    null
  </code></pre>
  
  <p>regards</p>