SELECT TOP 10 *
FROM
(
SELECT ROW_NUMBER() OVER (ORDER BY D.RECORD_ID) AS RowNumber,D.RECORD_ID,D.RECORD_VALUE,D.RECORD_TIME,M.CHECK_PROJECT FROM DATA_RECORD_HISTORY D INNER JOIN MONITOR M ON(D.MONITOR_ID=M.MONITOR_ID)
WHERE M.MONITOR_ID=1
) AS TEMP
WHERE TEMP.RowNumber > 0
比
SELECT TOP 10 * FROM DATA_RECORD_HISTORY D INNER JOIN MONITOR M ON(D.MONITOR_ID=M.MONITOR_ID) WHERE M.MONITOR_ID=1 AND D.RECORD_ID
NOT IN(SELECT TOP 10 DD.RECORD_ID FROM DATA_RECORD_HISTORY DD INNER JOIN MONITOR MM ON(DD.MONITOR_ID=MM.MONITOR_ID) WHERE MM.MONITOR_ID=1)
高效!
并且下面这条语句的条件必须在两条select语句中都带着!在多条件分页查询中不是很方便。