title: SELECT TOP 1 is returning multiple records
body: <p>I shall link my database down below.</p>
  
  <p>I have a query called 'TestMonday1' and what this does is return the student with the fewest 'NoOfFrees' and insert the result of the query into the lesson table. Running the query should help explain what i mean. The problem im having is my SQL code has 'SELECT TOP 1' yet if the query returns two students who have the same number of frees it returns both these records. Wit this being a timetable planner, it should only ever return one result, i shall also put the code below,</p>
  
  <p>Many thanks </p>
  
  <p>Code:</p>
  
  <pre><code>INSERT INTO Lesson ( StudentID, LessonStart, LessonEnd, DayOfWeek )
  SELECT TOP 1 Availability.StudentID, Availability.StartTime, 
               Availability.EndTime, Availability.DayOfWeek
  FROM Availability
  WHERE 
    Availability.StartTime='16:00:00' AND 
    Availability.EndTime='18:00:00' AND 
    Availability.DayOfWeek='Monday' AND 
    LessonTaken IS NULL
  ORDER BY 
    Availability.NoOfFrees;
  </code></pre>