-1

I have a result set that contains about 800 records, how can I split them into eight parts, which contain 100 records for each column?

Note: for the result set, there is ONLY one column which is that one contains 800 rows, so it seems impossible to get each 100 by using 'select...where ID between 1 and 100'; 'select...where ID between 101 and 200' etc.

Any idea guys? Appreciate it in advance

Eduardo Herrera
  • 79
  • 1
  • 15
LONG
  • 4,490
  • 2
  • 17
  • 35

1 Answers1

0

You can use this? Just set your limits between the rownum >= and the rownum < 200

;WITH Results_CTE AS
(
    SELECT
        Col1, Col2, ...,
        ROW_NUMBER() OVER (ORDER BY SortCol1, SortCol2, ...) AS RowNum
    FROM Table
    WHERE <whatever>
)
SELECT *
FROM Results_CTE
WHERE RowNum >= 100
AND RowNum < 200
Tschallacka
  • 27,901
  • 14
  • 88
  • 133