MATCH_NUMBER

MATCH_NUMBER is a value from the Ranking window functions in SQL Server. It provides a unique row number for each row regardless of duplicates within a partition. It's calculated for the result set partition, ordered by the defined ORDER BY clause in the ranking function.

Example

SELECT MATCH_NUMBER() OVER ()
FROM dual;

Output

MATCH_NUMBER() OVER ()
--------------------------
1

Explanation

In this example, the MATCH_NUMBER function is used to provide a unique number for each match generated by a pattern within a MATCH_RECOGNIZE clause. As the MATCH_RECOGNIZE clause is not used in this query, default match number returned is 1.

For in-depth explanations and examples SQL keywords where you write your SQL, install our extension.