Via Cà Matta 2 - Peschiera Borromeo (MI)
+39 02 00704272
info@synaptica.info

Firebird 3 – How to get record number of dataset

Digital Innovation Partner

Firebird 3 – How to get record number of dataset

How to get record number of dataset using row_number window function with over().

SELECT 
 row_number() over(), 
 t.* 
FROM test t

Example of record number of dataset with even and odd column sorting.

SELECT 
    row_number() over(),
   (CASE WHEN mod(row_number() over(),2) = 0 THEN 'even' ELSE 'odd' END) AS my_column,
   custom.* FROM
  (
 SELECT
 t.* 
FROM test t ORDER BY t.description
) custom