ROW_NUMBER Alt in SQL Server 2000

Posted by harekam_taj on Stack Overflow See other posts from Stack Overflow or by harekam_taj
Published on 2010-06-17T19:08:19Z Indexed on 2010/06/17 19:13 UTC
Read the original article Hit count: 224

Hey Guys,

Can anyone please help me with an alt. to ROW_NUMBER in SQL Server 2000.

RIGHT now my procedure looks like this in SQL Server 2008

WITH cars as(SELECT carid,mileage,retailprice,imageurl,model,year, Zips.Distance AS Miles, Manufacturers.mfgName as Make,dealers.companyname as companyname, CASE @sortby 
WHEN 'D' THEN ROW_NUMBER() OVER (ORDER BY  Manufacturers.mfgName) 
WHEN 'P' THEN ROW_NUMBER() OVER (ORDER BY retailprice) 
WHEN 'M' THEN ROW_NUMBER() OVER (ORDER BY mileage) 
END as 'rownum'
FROM usedcars INNER JOIN #TempZips Zips ON Zips.ZipCode =usedcars.loczip
left join Manufacturers on Manufacturers.mfgid=usedcars.mfgid left join dealers on dealers.dealerid = usedcars.dealerid 
where usedcars.active=1 and usedcars.dealerid=@dealerid)
select @totalrecords as totalrec,*  from cars where rownum between @skip and  @take

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server-2005