title: Randomly select rows in HIVE, half of which must satisfy a condition
body: <p>Right now I have:</p>
  
  <pre><code>SELECT id, name FROM table1
     DISTRIBUTE BY rand()
     SORT BY rand()
     limit 2;
  </code></pre>
  
  <p>But I need to add a qualifying statement so that half of the randomly retrieved rows satisfy a specified condition: </p>
  
  <pre><code>WHERE count(id) &gt; 3
  GROUP BY name;
  </code></pre>
  
  <p>while the other half of the rows do NOT satisfy this condition. However, I can't have one subset more overrepresented than the other i.e. those who have a count(id) > 3 should be the same amount as those &lt;3. I thought of using a union, but think that's not possible as the queries will be querying the same table. How do I do this? Thanks in advance!</p>