how to uniformly select rows in sql I am new to here and please let me know if I didn't make the question clearly.

If I have a m rows in a table and I want to select n rows uniformly. In other words, the interval between first row and next row is m / n.

For example, if i have a 10 rows and I want to select 5 rows out of them, then the selected rows would be 1, 3, 5, 7, 9 because the interval is 10 / 5 = 2.

Does anyone can help?
You can use row_number and the modulo operator

Tables don't have any inherent order. You need to define an ordering expression (e.g column names) to define what "first" and "next" mean.

DECLARE @StepSize int = 2;

WITH CTE AS
(
SELECT *,
       ROW_NUMBER() OVER (ORDER BY YourOrderingColumn) AS RN
FROM YourTable
)
SELECT *
FROM CTE
WHERE RN % @StepSize = 1;