Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

take a look here: Row Offset in SQL ServerRow Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

deleted 2 characters in body
Source Link
user2366842
  • 1.2k
  • 14
  • 23

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow`@endRow

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 a.Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow`

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 a.Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

added 584 characters in body
Source Link
user2366842
  • 1.2k
  • 14
  • 23

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow`

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 a.Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow`

replace @startRow and @endRow with your starting and ending row numbers.

take a look here: Row Offset in SQL Server It looks as though there's no direct equivalent keyword, however the same effect can still be achieved via a little bit of a workaround.

SELECT Job_No
FROM (
SELECT Job_No, ROW_NUMBER() OVER (ORDER BY ID) AS RowNum
FROM MyTable
) AS MyDerivedTable
WHERE MyDerivedTable.RowNum BETWEEN @startRow AND @endRow`

replace @startRow and @endRow with your starting and ending row numbers.

Update: Basing on updated info in the question:

 SELECT 
 a.Job_No 
 FROM (
 SELECT 
 ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum 
 FROM dbo.ScheduledatesFF AS a 
 INNER JOIN dbo.tblCustomers AS c 
 ON a.Job_No = c.Job_No 
 INNER JOIN dbo.scheduledatesSS AS z 
 ON a.Job_No = z.Job_No 
 LEFT OUTER JOIN dbo.maxscheddate AS m 
 ON a.Job_No = m.Job_No
 ) AS MyDerivedTable 
 WHERE MyDerivedTable.RowNum BETWEEN 0 AND 20

That's my best guess anyways. It looks like you had 2 from statements back to back....

Please use the {} code button to format blocks of code
Source Link
Aaron Bertrand
  • 282.4k
  • 37
  • 471
  • 469
Loading
added 73 characters in body
Source Link
user2366842
  • 1.2k
  • 14
  • 23
Loading
Source Link
user2366842
  • 1.2k
  • 14
  • 23
Loading