sql server - select top and bottom rows

Posted by Adrian Faciu on Stack Overflow See other posts from Stack Overflow or by Adrian Faciu
Published on 2010-05-28T08:04:41Z Indexed on 2010/05/28 8:11 UTC
Read the original article Hit count: 246

Filed under:
|
|

Hi,

I'm using Sql Server 2005 and i'm trying to achieve something like: In the same select statement i want to get the first x rows and the last x rows.

SELECT TOP(5) BOTTOM(5)

Of course 'bottom' does not exist so i need other solution. I believe there is an easy and elegant solution that i'm not getting. Doing the select again with Group By Desc is not an option.

Thanks.

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2005