Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi there
While loading my table, I would like to establish an subselect on the same data source.
Entry | Timestamp | EventId | PartnerEventId | TimestampPartner | |
2569 | 10.06.2024 00:40:00.00 |
|
15 | ||
2570 | 10.06.2024 00:56:53.53 | 3 | 7 | ||
2571 | 10.06.2024 01:25:00.00 | 12 | 5 | 10.06.2024 00:40:00.00 | |
2572 | 10.06.2024 01:39:33.33 | 3 | 7 | ||
2573 | 10.06.2024 02:15:57.57 | 5 | 15 |
When e.g. loading line 2571 I would like to lookup the TimestampPartner according to PartnerEventId = EventId and having the next older timestamp.
A "classic" SQL statement could look like:
SELECT LIMIT 1
timestamp
FROM table t
WHERE t.timestamp < timestamp AND PartnerId = t.EventId
ORDER BY t.Timestamp DESC
Any suggestions are welcome. Thanks!
I expanded the example a bit to have multiple partner events that we should find the nearest, earlier timestamp for. Did I understand the problem correctly?