title: SQL Server - Select one random record not showing duplicates
body: <p>I have two tables, events and photos, which relate together via the 'Event_ID' column. I wish to select ONE random photo from each event and display them.</p>
  
  <p>How can I do this?</p>
  
  <p>I have the following which displays all the photos which are associated. How can I limit it to one per event?</p>
  
  <pre><code>SELECT Photos.Photo_Id, Photos.Photo_Path, Photos.Event_Id, Events.Event_Title,
     Events.Event_StartDate, Events.Event_EndDate FROM Photos, Events 
  WHERE 
     Photos.Event_Id = Events.Event_Id AND 
     Events.Event_EndDate &lt; GETDATE() AND 
     Events.Event_EndDate IS NOT NULL AND
     Events.Event_StartDate IS NOT NULL
  ORDER BY NEWID()
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Luke Stratton</p>