I'm trying to figure out how to make a query show me only when an object has touched a specific systemic location based on time stamp. For example:
Query:
SELECT
id,
timestamp,
lp,
location
FROM
unit_location
WHERE
lp IN (
'1234',
'9999');
id timestamp lp location
11110000 11-APR-23 15:05:31 1234 Location 2
22220000 11-APR-23 15:22:52 1234 Location 1
33330000 11-APR-23 15:35:10 1234 Location 2
44440000 11-APR-23 15:04:11 9999 Location 2
55550000 11-APR-23 19:29:04 9999 Location 1
66660000 11-APR-23 19:40:14 9999 Location 2
How would I make it so that a query could run and it would only bring back the data for the last timestamp but only if its location 2 for each individual lp?
Example here, it would only show me ID:
id timestamp lp location
33330000 11-APR-23 15:35:10 1234 Location 2
66660000 11-APR-23 19:40:14 9999 Location 2
I'd tried to use MAX on time stamps based on some where critera and a few other little bits and bats but was not able to replicate the result I needed.