I’m sure someone will have a very simple answer to this but I can’t work it out for the life of me: I have 3 tables that look something like this:
Vehicles: Vehicle_id, Reg_number...
Datalogger: Logger_id, event, status, date...
Vehicle_Loggers: Vehicle_id, Logger_id, installed_from, installed_to
(Relationships are on columns with the same name here)
Using these tables how would I get the whole history of a given vehicle’s logs (event and status) even if it has had multiple loggers fitted at different times?
I know this can be done using a cursor but as this is really a set operation (Get the set of loggers that have been attached to the vehicle, then get the reports of each logger using the given date range for that logger)
EDIT: Loggers can be used in more than one vehicle during their lifetime, hence the inclusion of the dates.
Thanks
Gareth
You can do it like this:
Just replace the Reg_number for the intended one.
To take in account the dates, possibly would be like this: