我有一个名为People
的表格,其中包含两列Name
& Age
。我想编写一个查询,它将检索Name列,并将row_number
合并到每一行。这样的事情: -
Name
-------------------
[ROW_NUMBER] Stan
[ROW_NUMBER] Alex
[ROW_NUMBER] Steven
行号为1,2,3,同时添加括号。
这就是我试过的
Select ( '[' + row_number() OVER (order by Name) + ']' + Name) From People
答案 0 :(得分:1)
Select '[' + cast(row_number() OVER (order by Name) as varchar(100)) + ']' + Name From People