title: SQL Server 2008: TOP 10 and distinct together
body: <p>As the title says, I'm using SQL Server 2008. Apologies if this question is very basic. I've only been using SQL for a few days. Right now I have the following query:</p>
  
  <pre><code>SELECT TOP 10 p.id, pl.nm, pl.val, pl.txt_val
  
  from dm.labs pl
  join mas_data.patients p    
    on pl.id = p.id
    where pl.nm like '%LDL%'
    and val is not null
  </code></pre>
  
  <p>What I want to do is use select top n together with distinct values in the id column. Searching through some forums says to use</p>
  
  <pre><code>SELECT DISTINCT TOP 10 ...
  </code></pre>
  
  <p>but when I replace the first line with</p>
  
  <pre><code>SELECT DISTINCT TOP 10 p.id, pl.nm, pl.val, pl.txt_val
  </code></pre>
  
  <p>I get the same results as without the word distinct. What should I be doing to only get to filter out duplicate id entries?</p>
  
  <p>Thank you.</p>