How can I return every nth record from a sub query based on a numerical parameter that I supply?
For example, I may have the following query:
SELECT
Id,
Key
FROM DataTable
WHERE CustomerId = 1234
ORDER BY Key
e.g.
The subquery result may look like the following:
Row Id Key
1 1 A3231
2 43 C1212
3 243 E1232
4 765 G1232
5 2432 E2325
...
90 3193 F2312
If I pass in the number 30, and the sub query result set contained 90 records, I would recieve the 30th, 60th, and 90th row.
If I pass in the number 40, and the result set contained 90 records, I would recieve the 40th and 80th row.
As a side note, for background information, this is being used to capture the key/id of every nth record for a paging control.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…