<p>Not sure how to ask a followup on SO, but this is in reference to an earlier question:
<a href="https://stackoverflow.com/questions/94930/fetch-one-row-per-account-id-from-list">Fetch one row per account id from list</a></p>

<p>The query I'm working with is:</p>

<pre><code>SELECT *
FROM scores s1
WHERE accountid NOT IN (SELECT accountid FROM scores s2 WHERE s1.score &lt; s2.score)
ORDER BY score DESC
</code></pre>

<p>This selects the top scores, and limits results to one row per accountid; their top score.</p>

<p>The last hurdle is that this query is returning multiple rows for accountids that have multiple occurrences of their top score. So if accountid 17 has scores of 40, 75, 30, 75 the query returns both rows with scores of 75.</p>

<p>Can anyone modify this query (or provide a better one) to fix this case, and truly limit it to one row per account id?</p>

<p>Thanks again!</p>

If you are selecting a subset of columns then you can use the DISTINCT keyword to filter results.
```
```
SELECT DISTINCT UserID, score
FROM scores s1
WHERE accountid NOT IN (SELECT accountid FROM scores s2 WHERE s1.score < s2.score)
ORDER BY score DESC
```
```