DECLARE @n int, @givenDate smalldatetime
SET @n = 4
SET @givenDate = '2009-12-13 04:00'
SELECT ID, [date&time], some_content_field
FROM ( SELECT TOP (@n) * FROM YourTable WHERE [date&time] <= @givenDate
ORDER BY [date&time] desc, ID desc) lastN
ORDER BY [date&time], ID
|