Frage

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
War es hilfreich?

Lösung

Select  '[' + cast(row_number() OVER (order by Name) as varchar(100))  + ']' + Name From People
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top