0

As the following SQL, it will select the 100 to 110th result matching the search condition. But I think the SQL is ugly (using twice condition where [name] like '%%') and there should be some brief statement to reach the same goal.

SELECT top 10 [name], [field1], [field2]
FROM [FrontPageInformation] 
WHERE [name] LIKE '%%' AND [name] NOT IN
      (SELECT TOP 100 [name] 
       FROM [EngineeringMedicine].[dbo].[FrontPageInformation] 
       WHERE [name] LIKE '%%')

Could anyone help?

Great thanks,

Wa

4

1 回答 1

4

您可以使用ROW_NUMBER()语法来获取行号

例如:

select [name],[field1],[field2] 
from
(
  SELECT [name],[field1],[field2], ROW_NUMBER() OVER (ORDER BY something) as RN
  FROM [FrontPageInformation]
  WHERE [name] like '%something%'
) v
WHERE RN between 101 and 110
于 2012-08-13T10:28:18.710 回答