哪位大神告诉我这条Sql哪里出错了
SQL code
SELECT
TOP 1
A.ID,
B.UserName,
A.AppOnDutyTime,
A.AppOffDutyTime,
A.OnDutyTime,
A.OffDutyTime,
C.OrganFullName
from
HandOversInfo A
join UserInfo B on A.UserID=B.UserID
join OrganInfo C on B.OrganID=C.OrganID
where A.ID not IN(SELECT TOP 1 ID FROM HandOversInfo)
我在做分页,HandOversInfo这张表里ID从25到32,这条连接查询为什么最终查出来的是ID为29的数据呢?怎么查出ID为26的这条数据啊,求大神帮帮忙啊
------解决方案--------------------
需要排序
SELECT
TOP 1
A.ID,
B.UserName,
A.AppOnDutyTime,
A.AppOffDutyTime,
A.OnDutyTime,
A.OffDutyTime,
C.OrganFullName
from
HandOversInfo A
join UserInfo B on A.UserID=B.UserID
join OrganInfo C on B.OrganID=C.OrganID
where A.ID not IN(SELECT TOP 1 ID FROM HandOversInfo Order by ID)
Order by A.ID