Add a sequential number to records returned by a query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How may I write a query so it adds a field to the information otherwise
returned which contains a sequential ID number?
 
Here's an example that works in Northwind:

SELECT
(SELECT COUNT(ProductName) FROM Products AS B
WHERE B.ProductName <= A.ProductName) AS Seq,
ProductID,
ProductName
FROM Products AS A
ORDER BY ProductName
;
 
Back
Top