Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pulling records

Status
Not open for further replies.

lah3233

MIS
Jul 15, 2003
33
US
We are trying to pull a record out of a table based on the number it is in result set. There is no actual number assigned to the row in the table. It somehow needs to be numbered after the query is pulled...without storing the number in the database. Does anyone out there have a way to solve this issue??
 
Hi,


Can u give the sample data, how it is to be ordered and how u want to show the rownumber. have a look at this SQL it will put a Serial no for each row returned from authors table in pubs DB

select (SELECT Count(au_id)+1 from authors a1 where a1.au_lname<a.au_lname) Rownumber
,au_id,au_lname,au_fname from authors a
order by au_lname asc

Hope it helps

Sunil

Sunil
 
Is there a property in SQL Server that gives you the row numbers so you don't have to use a count in the select statement?
 
Hi,

There is no function in SQL Server that will return the row number

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top