MS SQL分页问题
select top 20 nEquipmentId,strEntName,strEquipmentType,strRegCode,strProduceCorp,strEquipmentModel,strEquipmentNumber,strEntEmail,strEquipmentDate,strMaxYear,strFlowName,nFlowState
from t_qyequipment
where nEquipmentId not in
(select top 360 nEquipmentId from t_qyequipment Where nFlowState>100 and 1=1 order by nFlowState ASC ) and nFlowState>100
ORDER BY nFlowState ASC
这是拼接好的SQL
在分到17页之后后面的记录就会跟之前一页的记录相同
到底是什么问题?
------解决方案--------------------
select top 20 nEquipmentId,strEntName,strEquipmentType,strRegCode,strProduceCorp,strEquipmentModel,strEquipmentNumber,strEntEmail,strEquipmentDate,strMaxYear,strFlowName,nFlowState
from t_qyequipment
where nEquipmentId not in
(select top 380 nEquipmentId from t_qyequipment Where nFlowState>100 and 1=1 order by nFlowState ASC ) and nFlowState>100
ORDER BY nFlowState ASC
红色部分的排序字段用主键看看!