I have a temporary table with these values:
product_id status_datetime status_code
45 1/3/1999 12:30 P
45 9/9/2000 10:20 S
45 6/6/2002 11:10 S
50 3/3/2003 09:30 S
67 4/5/2003 04:40 S
67 8/8/2004 12:20 P
I want to pull only the most recent values from this table by product_id - in other words, from this list, I would want to return:
product_id status_datetime status_code
45 6/6/2002 11:10 S
50 3/3/2003 09:30 S
67 8/8/2004 12:20 P
I'm not exactly sure how to use max() and/or select top x over a unique index...any help greatly appreciated.
product_id status_datetime status_code
45 1/3/1999 12:30 P
45 9/9/2000 10:20 S
45 6/6/2002 11:10 S
50 3/3/2003 09:30 S
67 4/5/2003 04:40 S
67 8/8/2004 12:20 P
I want to pull only the most recent values from this table by product_id - in other words, from this list, I would want to return:
product_id status_datetime status_code
45 6/6/2002 11:10 S
50 3/3/2003 09:30 S
67 8/8/2004 12:20 P
I'm not exactly sure how to use max() and/or select top x over a unique index...any help greatly appreciated.