title: MS SQL distinct function
body: <p>I have the query below</p>
  
  <pre><code>SELECT distinct
  count(patient.id)
  CAST(YEAR(completiondate) AS VARCHAR(4)) + '-' +  CAST(MONTH(completiondate) AS VARCHAR(2))   AS Mjesec
  
  FROM ....
  
  WHERE 
  incident.completionDate Between Convert(smalldatetime, '01/10/2007', 103) and Convert(smalldatetime, '01/11/2013', 103) 
  and servicecharges.serviceid in (47)
  
  and incident.status != 6
  and ServiceRequestDescription LIKE 'something'
  and chargeDescr = 'test'
  
  group by CAST(YEAR(completiondate) AS VARCHAR(4)) + '-' +  CAST(MONTH(completiondate) AS VARCHAR(2))
  </code></pre>
  
  <p>the result i take, have unique rows of patient.id AND Year-Month. That means that i can have multiple rows with the same patient.id and several year-month.</p>
  
  <p>how can i change that query, in order to take the results, with each patient.id only once, with the first completiondate with the specific elements?</p>