SQL: Add column with incremental id to SELECT

前端 未结 4 2323
迷失自我
迷失自我 2021-02-19 03:57

I have a simple query like:

SELECT name FROM people;

The people table does not a have unique id column. I want to add to the query r

4条回答
  •  清歌不尽
    2021-02-19 04:54

    The row_number window function should fit the bill:

    SELECT ROW_NUMBER() OVER (ORDER BY 1), *
    FROM   people
    

提交回复
热议问题