title: Impala query to get sample value of column used in count aggregate function
body: <p>I have huge data in hive table. PFB sample rows.</p>
  <p>Table:</p>
  <pre><code>Clid,pid,lid
  1 ,1 ,OJA
  1 ,2 , KLM
  1, 2 , MHK
  1 ,2, DNY
  </code></pre>
  <p>I want to write impala query to get count of lid for each clid,pid group along with sample value.
  I know how to get count but how can I get sample value of lid for each clid, pid group.</p>
  <p><code>Select clid, pid, count(lid) frim t group by clid,pid</code></p>
  <p>What should I add in impala query to get sample lid as shown in below result.</p>
  <p>Expected result:</p>
  <pre><code>Clid, pid, count, sample lid
  1, 1, 1, OJA
  1, 2,3,MHK
  </code></pre>
  <p>I have tried using first_val function with over clause but it's giving error.</p>
  <p><code>select clid,pid, count (lid), first_value(lid) over (partition by clid, pid) from t group by clid, pid</code></p>
  <p>Error:</p>
  <p>AnalysisException: select list expression not produced by aggregation output (missing from GROUP BY clause?):
  first_value(lid) OVER (PARTITION BY clid,pid)</p>