go to post Anil Kumar Agrawal · Sep 1, 2020 Assumption here is that the Timestamps and IDs are in the same order, in that case you don't need the order by clause in the where. SELECT ID, TS, Data FROM TSOrderWHERE ID >= (SELECT TOP 1 ID FROM TSOrder WHERE TS >='2016-07-01 00:00:00.00000')AND ID <= (SELECT TOP 1 ID FROM TSOrder WHERE TS >='2016-07-01 23:59:59.999999')