Query to get the desired output in sql server without temp table [Resolved]

Posted by Laghaterohan under Sql Server on 10/19/2011 | Points: 10 | Views : 951 | Status : [Member] | Replies : 2
HI,
can any one help me to know the syntax for the following output.
I am selecting one column from a table and then besides this column I need another column (not from the table) that just displays a row number one after the another look below.

NAME NO
---------------- -------------
A 1
B 2
C 3
D 4
E 5

I don't want to use temperory tables either.

Thanks!

Best Regards,
Rohan Laghate



Responses

Posted by: Laghaterohan on: 10/19/2011 [Member] Starter | Points: 25

Up
0
Down

Resolved
Many thanks!!!

Regards,
Rohan

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hmanjarawala on: 10/19/2011 [Member] Bronze | Points: 25

Up
0
Down
select name,row_number() over (order by name) as no from <table-name>

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response