I have a machine logging production info to a database whenever certain conditions change state, so pretty much randomly throughout the day. The plant runs 24/7 so data is continuously flowing into it with about 500 entries in a 24 hour cycle.
The shifts are strictly time based and are as follows,
07:20-15:20 (day shift)
15:20-11:20 (swing shift)
11:20-07:20 (night shift)
I need to select all of the last entries for each shift, so the results should look something like this:
id | timestamp | bags_packed 34 | 2010-10-02 15:19:24 | 21320 73 | 2010-10-02 11:19:12 | 18432 93 | 2010-10-03 07:19:42 | 15035 163 | 2010-10-03 15:18:56 | 23937 194 | 2010-10-03 11:19:53 | 19304
(theres a whole lot more info than just bags_packed, but I'm keeping it simple)
So I am left with the final results for every shift and I can use this information to generate shift report trends over the year etc.
Edited by muppet: n/a