EFileTahi-A
Well-known member
Imagine that I have a table with 100 records and that I need to select all records from position 20 to 50...
How?
Thank you...
How?
Thank you...
DECLARE @RangeStart int
SET @RangeStart = 20
DECLARE @StartPoint int
SET @StartPoint = (SELECT MAX([PrimaryKey])
FROM (SELECT TOP 20 [PrimaryKey] FROM [MyTable]) T)
SELECT TOP 10 * FROM [MyTable] WHERE [PrimaryKey] > @StartPoint
Mister E said:This might be a way to do what you need:Code:DECLARE @RangeStart int SET @RangeStart = 20 DECLARE @StartPoint int SET @StartPoint = (SELECT MAX([PrimaryKey]) FROM (SELECT TOP 20 [PrimaryKey] FROM [MyTable]) T) SELECT TOP 10 * FROM [MyTable] WHERE [PrimaryKey] > @StartPoint
you may using Between or In method in sql query,EFileTahi-A said:Imagine that I have a table with 100 records and that I need to select all records from position 20 to 50...
How?
Thank you...
Well that assumes that "Code" is completely sequential, which is not guarenteed. If there are any gaps in "Code" between 20 and 50, then youre not going to get a range of 30 records.bshaen said:you may using Between or In method in sql query,
SELECT * FROM Table_name WHERE Code BETWEEN "20" AND "50"
or
SELECT * FROM Table_name WHERE Code IN "20" TO "50"