ROW_NUMBER Allows you to provide sequential integer values to the result rows of a query. The below code snippet is an example that shows how the ROW_NUMBER() function can provide an ascending number for each row returned when inspecting the Employee view. The ROW_NUMBER() function is nondeterministic.
SELECT ROW_NUMBER() OVER(ORDER BY LastName) AS RowNum,
FirstName + ' ' + LastName
FROM HumanResources.Employee
WHERE JobTitle = 'DatabaseDesign'
ORDER BY LastName
Saturday, February 23, 2008
ROW_NUMBER
Labels:
Analytical Functions,
SQL,
SQL Server,
SQL Server Tips
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment