HamidReza
HamidReza

Reputation: 1

obtain number row in access

SQL Server:

SELECT col1, col2,ROW_NUMBER() OVER (order BY col1) AS intRow FROM Table1 

What is the equivalent code in Access?

Upvotes: 0

Views: 1414

Answers (1)

Thomas
Thomas

Reputation: 64645

In short, there is no equivalent. If you want a sequence, one way to do it is to create a table with an AutoNumber column. Another way would be something like:

Select ..,
    , (
        Select Count(*)
        From MyTable As T1
        Where T1.PrimaryKeyCol < T.PrimaryKeyCol
        ) + 1 As Seq
From MyTable As T

However, if the table is large, that may not perform well.

Upvotes: 1

Related Questions