SQL: Add column with incremental id to SELECT

前端 未结 4 2344
迷失自我
迷失自我 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

    If you need it only when the query is run, you can use row_number.

    select row_number() over(order by name) as id, name
    from people
    

提交回复
热议问题