If you have created the column row_id
like:
ROW_NUMBER() OVER (ORDER BY registration_number)
then use a CTE
:
WITH cte AS (
SELECT *, ROW_NUMBER() OVER (ORDER BY registration_number) row_id
FROM tablename
)
SELECT *
FROM cte
WHERE registration_number = ?
Replace ?
with the registration number that you want to search for.
Another way of getting the row_id
would be with a correlated subquery:
SELECT t.*,
(SELECT COUNT(*) FROM tablename WHERE registration_number <= t.registration_number) AS row_id
FROM tablename AS t
WHERE t.registration_number = ?