I have a query like so: SELECT TOP 20 a.Job_No FROM dbo.ScheduledatesFF
Which gives me the first 20 results, but I want to start at 20 and get 20 results, how do I set an Offset?
I tried: OFFSET 20 at the end of the query and I got this error:
Incorrect syntax near 'OFFSET'
I know in mysql its Offset, is it something different in SQL?
This gives me an error:
SELECT
a.Job_No
FROM (
SELECT
ROW_NUMBER() OVER (ORDER BY a.Job_No) as RowNum
FROM dbo.ScheduledatesFF
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
Incorrect syntax near the keyword 'FROM'.
This is the closest I have come:
SELECT a.Job_No, ROW_NUMBER() OVER (ORDER BY a.Job_No) as datacounter 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
but in the where clause for datacounter it says it does not exists