Skip to content
Advertisement

How do I get the latest records from every customer with a time delta

I want to get the most recent records for every customer and also accept/get records which are 1 hour older to the most recent record.

I am currently getting the most recent records for every customer using this SQL query –

What I need is to get the most recent records and records which are an hour older than the recent records for every customer.

Advertisement

Answer

Hmmm . . . You can get the maximum timestamp and use date comparisons:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement