Вопрос

I have a table called People that has two columns, Name & Age. I'd like to write a query that will retrieve the Name column with the row_number merged into each row. something like this : -

       Name
-------------------
[ROW_NUMBER] Stan
[ROW_NUMBER] Alex
[ROW_NUMBER] Steven

Row number being 1,2,3, Whilst adding the brackets as well.

This is what I tried

Select ( '[' + row_number() OVER (order by Name) + ']' + Name) From People
Это было полезно?

Решение

Select  '[' + cast(row_number() OVER (order by Name) as varchar(100))  + ']' + Name From People
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top