I don't think you need to determine the max across all of the timestamps here. Just use the `end_timestamp`. The `first_timestamp` column on the `machine` table just needs to correspond to when we first received data from that machine. The `last_timestamp` should correspond to the last timestamp associated with data generated from that machine. The call to `max()` is always going to return the `end_timestamp` here.