1SELECT t.A, t.B, t.C, ROW_NUMBER() OVER (ORDER BY t.A) as newId
2 FROM dbo.tableZ AS t
3 ORDER BY t.A;
1-- Uses AdventureWorks
2
3SELECT ROW_NUMBER() OVER(ORDER BY SUM(SalesAmountQuota) DESC)
4 AS RowNumber,
5 FirstName, LastName,
6 CONVERT(varchar(13), SUM(SalesAmountQuota),1) AS SalesQuota
7FROM dbo.DimEmployee AS e
8INNER JOIN dbo.FactSalesQuota AS sq
9 ON e.EmployeeKey = sq.EmployeeKey
10WHERE e.SalesPersonFlag = 1
11GROUP BY LastName, FirstName;
12
1SELECT
2 ROW_NUMBER() OVER (
3 ORDER BY first_name
4 ) row_num,
5 first_name,
6 last_name,
7 city
8FROM
9 sales.customers;
10