create rownum in sql code example
Example 1: create row number in sql
SELECT t.A, t.B, t.C, ROW_NUMBER() OVER (ORDER BY t.A) as newId
FROM dbo.tableZ AS t
ORDER BY t.A;
Example 2: rownum in sql
SELECT ROWNUM, a.*
FROM (SELECT customers.*
FROM customers
WHERE customer_id > 4500
ORDER BY last_name) a;