I have the following problem:
1) I need to create another table with the same attributes but only from these rows that have the latest sampling date (max(sampledate)). The sampling date denotes the beginning of the sampling and it is same for all products being sampled at the time.
First idea to solve this problem is to get all rows with the latest sampling date and put all these rows in new table
INSERT INTO current_product VALUES(SELECT * FROM PRODUCT WHERE sampledate=(SELECT MAX(sampledate) FROM PRODUCT))
Is there any more efficient way to do this like cut off the part of table on some condition
2) I need to check if there were some changes in attributes between products with the same id but different sample date. I can group the rows with the same id and then start checking each attribute but is there a more efficient way in solving this?