Hi,
I have “Table1” as shown above with some records on it and the column names are Id, Name and [Entry Date]. Column Id is primary key, I am using SQL Server 2005.
I want to write a query that returns information every 5 records, for example my query will return:
As you can see in the final result only the record every 5 records was selected, how can I accomplish this?
Thank you
SELECT id, name, entryDate
FROM (SELECT ROW_NUMBER() OVER(ORDER BY id) rowNumber, Id, name, entryDate
FROM MyTable)
WHERE rowNumber = 1
OR rowNumber % 5 = 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With