I have table called “Factory1” (MS SQL Server) containing columns LOT and Counter:
During the shift, at the end of every batch the counter is reset. I have to write query showing the running (and finished batches if any) and the corresponding counter values at the end of every shift. Any hints?
A query could look something like this:
SELECT LOT, MAX(Counter) FROM Factory1
GROUP BY LOT
ORDER BY LOT
Should the table not be updated instead of inserted to every time, so that the 0 counter value is replaced with the actual counter number? Otherwise you’ll end up with double the data usage for (seemingly) no reason
If it’s also stored with a timestamp, it can also be used to calculate efficiency trends and hourly counts. Not enough information to say from the available data.
Thank you both for your new inputs. I use this script in report. It works perfectly, just as intended, I wonder how I was not be able to figure it out earlier - OK, my SQL knowledge is pretty basic.