Created
April 9, 2015 10:47
-
-
Save anonymous/d131d9f6c7bfa68d1385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF OBJECT_ID('tempdb..#rowCountTB') IS NOT NULL | |
DROP TABLE #rowCountTB; | |
WITH DistinctTable | |
AS ( | |
SELECT DISTINCT [fieldValue] | |
FROM [tableName] | |
) | |
,RowNumber | |
AS ( | |
SELECT ROW_NUMBER() OVER ( | |
ORDER BY [fieldValue] | |
) AS RowNum | |
,[fieldValue] | |
FROM DistinctTable | |
) | |
SELECT * | |
INTO #rowCountTB | |
FROM RowNumber | |
ORDER BY [fieldValue] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment