SELECT TOP 1 is returning multiple records

前端 未结 1 946
一整个雨季
一整个雨季 2021-01-19 00:22

I shall link my database down below.

I have a query called \'TestMonday1\' and what this does is return the student with the fewest \'NoOfFrees\' and insert the resu

相关标签:
1条回答
  • 2021-01-19 01:04

    This happens because Access returns all records in case of ties in ORDER BY (all records returned have the same values of fields used in ORDER BY).

    You can add another field to ORDER BY to make sure there's no ties. StudentID looks like a good candidate (though I don't know your schema, replace with something else if it suits better):

    ORDER BY 
      Availability.NoOfFrees, Availability.StudentID;
    
    0 讨论(0)
提交回复
热议问题