SQL to output line number in results of a query

后端 未结 5 483
忘了有多久
忘了有多久 2021-01-07 17:38

I would like to generate a line number for each line in the results of a sql query. How is it possible to do that?

Example: In the request

select di         


        
5条回答
  •  抹茶落季
    2021-01-07 18:10

    OR you could also do

    SELECT DISTINCT client_name, @num := @num + 1 AS lineNum(this is your new col)
    FROM deliveries
    JOIN (SELECT @num :=0) AS n ON 1=1;
    

    hope this helps too :)

提交回复
热议问题