August 5, 2009 at 3:24 pm
Hello,
I have data like:
Gold 111
Silver 222
Bronze 333
Now I need to return result like:
1 Gold 111
2 Silver 222
3 Bronze 333
What's the simple approach to this? Thanks.
August 5, 2009 at 3:41 pm
August 5, 2009 at 3:45 pm
I was just going to suggest RowNumber as well
CREATE TABLE #tmpdta (Mat VARCHAR(25), num INT)
INSERT INTO #tmpdta (
Mat,
num
) VALUES
('Gold',111 ),
('Silver',222 ),
('Bronze',333 )
SELECT ROW_NUMBER() OVER(ORDER BY NUM DESC ) AS RowNumber,*
FROM #tmpdta
** My Insert into used a SS2k8 ability
August 5, 2009 at 3:48 pm
But then again, if you wanted really simple, you could just do:
...
select right(field2,1),field1,field2
from x
but I'm guessing that those numbers are made up 😛
August 6, 2009 at 7:14 am
Thanks for the answer.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply