Have you ever wanted to have a row count as a column in sql output?
Well, I have for a number of different reasons and this is how I found to do it.
ROW_NUMBER() OVER(Order by ‘SomeColumn’) as seq
Have you ever wanted to have a row count as a column in sql output?
Well, I have for a number of different reasons and this is how I found to do it.
ROW_NUMBER() OVER(Order by ‘SomeColumn’) as seq
If I’m doing as such:
SELECT COUNT(*) FROM tblA
UNION
SELECT COUNT(*) FROM tblB
UNION
SELECT COUNT(*) FROM tblC
But want to add a row number before each record, how would I achieve that?
I know I’m raising a post from the grave here.