Table and machine monitoring use

Hello guys,
I am developping an app base on machine monitoring and tables at the same time. So, what i want to do is to get a counter value from a machine over the OPC server, save this value (Counter_piece for example) every 10 minutes using a trigger in the master layout (untill now evething is okay). My problem begin now. With this counter i have also to create two other tables : one to save the value of counter_piece(N-1) (the value of counter_piece that i have saved &à minutes before) and an other one for susbstaction result between (counter_piece(N) - counter_piece(N-1)). So my question is how can i do save the value of counter_piece(N) (10 minute ago) into the new table counter_piece(N-1) and do this every 10 minutes)?
thank you for your help,

Do you really mean tables when you say tables or are you just talking about holding on to these values in variables for the 10 minute intervals?

If you really mean tables, I don’t see why you need 2 separate tables for N and N-1. Make a table with an ID column, a column for N and a . When you get a new N value, create a new table record and grab the ID of that record. Use that to get the N value for record ID - 1, subtract it from your current N and you have your difference variable. You could store that difference value in the table but it’s always available by doing the math on your column of Ns.

Okay i see. But my only problem is that i am using IDs based on our number of WO i mean if for example we are working on the WO ‘001’ i will create a table record with the ID : 001-“Randomstring()” so is it possible to create for example the new record with this ID and at the same Time save this ID to use it when i will do the math substraction of the two records (N and N-1)?
thank you,

I think the answer is to not use your work order information as the ID for the table record. Keep a separate ID column and let it auto-increment.