Hi,
I've got a table "state" which holds states for products, every insert made
on this table is inserting values and
value called "whenaction" where is the time (as timestamp) of the insert, so
table cound look like this:

id|amount|product_id|whenaction
1  50     2          1111115621
2  45     2          1232546487
3  60     1          4564124548
4  54     1          5648721323
5  54     3          8745432188
6  89     1          5454123123

and I need "For each product find record that has been last inserted" :

id|amount|product_id|whenaction
2  45     2          1232546487
4  54     1          5648721323
5  54     3          8745432188

and this does not works... why???

SELECT id,amount, product_id,whenaction
FROM   state as s1
WHERE  whenaction=(SELECT MAX(s2.whenaction)
              FROM state s2
              WHERE s1.product_id = s2.product_id);



Brona


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to