I have a numeric field (say num) in table along with pkey.
select * from mytable order by num
now how I can get the row no in query output of a particular row for which I have pkey.
I’m using sql 2000.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sounds like you want a row number for each record returned.
In SQL 2000, you can either do this:
which assumes num is unique. If it’s not, then you’d have to use the PK field and order by that.
Or, use a temp table (or table var):
In SQL 2005, there is a ROW_NUMBER() function you could use which makes life a lot easier.