Simulate Rownumber (a la Oracle?)

,

Shows how to return data with a "rownumber". Some unique column is needed.

USE Northwind
go
DECLARE @search varchar(55)
SET @search = '%f%'

SELECT (SELECT COUNT(*)
        FROM Customers AS U2
        WHERE U2.CustomerID <= U1.CustomerID
        AND   U1.CustomerID LIKE @search) AS Rowno
        , U1.CustomerID
        , U1.CompanyName
FROM Customers AS U1
WHERE U1.CustomerID LIKE @search

Rate

5 (1)

Share

Share

Rate

5 (1)