Need to edge out the competition for your dream job? Train for certifications today.
SELECT * FROM my_report_table ORDER BY col_01 ASC
Open in new window
WITH cte_nums AS (
SELECT n = ROW_NUMBER() OVER (ORDER BY a.object_id, b.object_id)
FROM sys.columns a, sys.columns b
cte_report AS (
SELECT *, n = ROW_NUMBER() OVER (ORDER BY col_01 ASC)
SELECT n.n, r.*
FROM cte_nums n
LEFT JOIN cte_report r ON n.n = r.n
WHERE n.n BETWEEN 1 AND 10
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.