sql 分页

最简单的分页(没考虑效率)

  SELECT TOP 10 [Id],[ReflectionId],[CreatorUserId],[Type],[Text],[AttachmentsJson],[CreatedTime]

  FROM [LeadersCorporationDB].[dbo].[ReflectionLog] 

  WHERE [ReflectionId]='2769D3CB-BB5C-47A1-9BF3-00C16614C4EB' AND 

  Id NOT IN(SELECT TOP ((2-1)*10+1) Id FROM [LeadersCorporationDB].[dbo].[ReflectionLog] 

    WHERE [ReflectionId]='2769D3CB-BB5C-47A1-9BF3-00C16614C4EB'

   ORDER BY CreatedTime)

  ORDER BY CreatedTime
NOT IN里边的条件、排序规则要和外层的相同!!!!

你可能感兴趣的:(sql)