Select first row in each group using group by in sqlite
<p>I have a table in sqlite. I am trying to get the first row of each group. Although there were earlier questions regarding the same. I couldn't find solution in sqlite. </p>

<p>My table looks like this:</p>

<pre><code>select * from geoview
MaxOfStatecountpercent | statepoolnumber | STATECODE
123                       1234              CA
123                       1234              FL
234                       1678              TX
234                       1678              MN
234                       0987              FL
234                       0987              CA
234                       9876              TX
</code></pre>

<p>I would like to query the first of MaxOfStatecountpercent and first of STATECODE from each statepoolnumber. The equivalent access sql query is :</p>

<pre><code>select first(MaxOfStatecountpercent), statepoolnumber, first(STATECODE) from geoview group by statepoolnumber;
</code></pre>

<p>And the output expected is :</p>

<pre><code>First(MaxOfStatecountpercent) | statepoolnumber | First(STATECODE)
123                             1234              CA
234                             1678              TX
234                             0987              FL
234                             9876              TX
</code></pre>

<p>I tried with "limit 1 " but did not work. How can i get a query equivalent in sqlite?</p>