May 12, 2011 at 12:33 am
hello everybody
i want to select 2 rows after last 2 rows
7aaaaaa
8bbbbbbb
9cccccccc
10dddddd
11eeeeee
top 2 is 7,8
i want to select after top 2 (9,10)
i hop anyone help me please
May 12, 2011 at 1:27 am
My solution would probably go along these lines:
SELECT TOP 2
*
FROM
(
SELECT TOP 4
ID, name
FROM #A
ORDER BY ID ASC
) A
ORDER BY ID DESC
Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2
May 12, 2011 at 1:28 am
Try this
select top 2 * from (select row_number() over (order by id ) row , * from tab)t where row>2
May 12, 2011 at 2:28 am
Thanx Ronald H , srikant maurya
it Solved the Problem
my Love ,, 😎
May 12, 2011 at 4:05 am
Love uh? That's a bit more appreciation than I expected 😉
Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply