N
N
Nikolai2021-05-03 08:44:21
SQL Server
Nikolai, 2021-05-03 08:44:21

What request to execute?

I have a table, I'm doing pagination for the site.

The last entry of the first "page" has EventID = 221316137

What query should be made to continue after the last EventID?

SELECT * FROM (
    SELECT 
    [Time] as [Timestamp],
    [EventID],
    DATEADD(MINUTE, ABS(TimeBias), CAST(([Time] / 864000000000.0 - 109207) AS DATETIME)) as [Date],
    ROW_NUMBER() OVER (ORDER BY Time desc) AS RowNum
    FROM [emsevents].[dbo].[Events] WHERE Time <= 132643456785317000 AND  Time >= 132643456770758000 
) AS result WHERE result.RowNum BETWEEN 1 AND 50


608f8e0790f47696415746.jpeg

SQL Server 2008

EventID is used a unique key, it is written to the database out of order

On the site, the user has several sorting options (date, alphabet, etc.)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question