WITH cte AS (
SELECT *, ROW_NUMBER() OVER (ORDER BY registration_number) row_id
FROM tablename
)
SELECT *
FROM cte
WHERE registration_number = ?
替换 ? 您要搜索的注册号。 另一种获得 row_id 将与相关子查询:
SELECT t.*,
(SELECT COUNT(*) FROM tablename WHERE registration_number <= t.registration_number) AS row_id
FROM tablename AS t
WHERE t.registration_number = ?
1条答案
按热度按时间m1m5dgzv1#
如果已创建列
row_id
比如:然后使用
CTE
:替换
?
您要搜索的注册号。另一种获得
row_id
将与相关子查询: