detox1978
asked on
TSQL: SELECT TOP 15 to 30 records?
Hi All,
I know it is possible to select the top 15 records via SELECT TOP 15, but how do i select the next 15.
i.e.
SELECT TOP 15 to 30 ?
I know it is possible to select the top 15 records via SELECT TOP 15, but how do i select the next 15.
i.e.
SELECT TOP 15 to 30 ?
ASKER
I Get an error;
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'where'.
Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'where'.
select * from
(select *, row_number() over(order by [ID]) seq from [MyDatabase].[dbo].[MyTable])
where seq between 16 and 30
ASKER
I'm using SQL express 2005
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER
Hi,
How do i filter the results above by another select query, so that only ID that are returned from another select statment below below are returned?
many thanks
How do i filter the results above by another select query, so that only ID that are returned from another select statment below below are returned?
many thanks
SELECT [ID] FROM [MyDatabase].[dbo].[MySecondTable]) Where [best]='5'
ASKER
I've opened another question for this;
https://www.experts-exchange.com/questions/24152475/TSQL-SELECT-data-based-on-another-SELECT-Statement.html
https://www.experts-exchange.com/questions/24152475/TSQL-SELECT-data-based-on-another-SELECT-Statement.html
select * from
(select *, row_number() over(order by col1) seq from Yourtable)
where seq between 16 and 30