Assumptions: 1) If the date and time are the actual date and time formats, this will be different. But, not knowing, I'm going to assume that they are strings (otherwise, why make them two columns?) Therefore, I am going to assume that they are YYYY-MM-DD and HH: MI respectively.
2) It seems reasonable that the OP wants to know these facts either SHIFT, or PRODUCT, or something. It would seem strange to just ask when they took the weight of anything. I guess this is from ProductNo.
3) This can be done in code, but my example is simpler if I create a table with a clock in it:
create table hours (hr varchar(2)); insert into hours ('01'); insert into hours ('02'); insert into hours ('03'); insert into hours ('04'); etc.
4) Tasks are somehow based on time - that is, a report for a specific period of time. In my example, I will select the month of September.
Task 1: find out what hours the operators took weight and what hours they did not.
select h.hr, o.productno, count(*) as nbr from hours h left outer join operator o on h.hr = substr (o.time, 1, 2) where o.date between '2011-09-01' and '2011-09-30' group by h.hr, o.productno
This should show a list of hours, and if measurements have been taken, the number of times these measurements have been taken during this hour for this product. If no measurements were made, the product would be empty due to an external connection, which I assume is what the OP forgot about.
Task 2: find out what hours the cars fell and what hours they were active.
I do not want to continue if the OP does not give some clue regarding my assumptions. Be that as it may, there is a very good chance that I completely lose time.
Task 3 and 4: compare the time during which the operators did not take the weight with the times when the machines were active, and determine if the machines were running, but there are no operator entries for the scales, when they should be.
I do not want to continue if the OP does not give some clue regarding my assumptions. Be that as it may, there is a very good chance that I completely lose time.