可能重复:
SQL Server 中的行偏移
我有一个类似条件的查询,它返回大约 1500 行。现在我想知道如何逐部分获取行,例如返回 75 行,然后再次返回接下来的 75 行,直到它到达行的末尾。我知道我可以使用类似的东西SELECT TOP 75
我尝试了这样的事情,但它没有返回任何行
SELECT *
FROM
(SELECT ROW_NUMBER() OVER (ORDER BY WarehouseSubType.id) as row,
WarehouseSubType.id,
WarehouseType.name as WarehouseTypename,
WarehouseType.alternateName AS WarehouseTypealternateName,
WarehouseSubType.name AS WarehouseSubTypename,
Warehouse.alternateName AS WarehousealternateName,
WarehouseSubType.alternateName AS WarehouseSubTypealternateName,
WarehouseSubType1.name AS WarehouseSubType1name,
WarehouseSubType1.alternateName AS WarehouseSubType1alternateName,
Warehouse.alternateName AS Warehousename,
Branch.name AS Branchname,
Branch.alternateName AS BranchalternateName,
WarehouseProductQuantity.actualQuantity,
WarehouseProductQuantity.reservedQuantity,
Supplier.companyName,
Supplier.companyNameAlternate,
Tafsil.description,
Tafsil.alternateDescription,
(WarehouseProductQuantity.actualQuantity - WarehouseProductQuantity.reservedQuantity) AS quantity
FROM WarehouseSubType
INNER JOIN WarehouseType ON (WarehouseSubType.warehouseTypeId = WarehouseType.id)
INNER JOIN WarehouseSubType1 ON (WarehouseSubType.id = WarehouseSubType1.warehouseSubTypeId)
) a
WHERE
warehouseTypename like '%Ve%'
AND row > 0 and row < 75