Im trying to select the entire row that has the heighest value in points. When Im trying to GROUP it turns out that I cant select entire row. So I came up with this query down here.
SELECT i1.*
FROM objects i1
LEFT OUTER JOIN objects i2
  ON (i1.product = i2.product AND i1.points < i2.points)
WHERE i2.product IS NULL and i1.product < $day
order by product asc, points desc
The table:
product   name      points   message
----------------------------------------
1         Joe       4        Message 1
2         Steve     15       Message 2
2         Loui      17       Message 3
3         Larry     10       Message 4
3         Harry     10       Message 5
3         Hank      8        Message 6
I want result like this:
product   name      points   message
----------------------------------------
1         Joe       4        Message 1
2         Loui      17       Message 3
3         Larry     10       Message 4
Now, product will be returned twice if two rows have the same points.
How can I select so I only got one row for each product with the highest points?
 
     
     
    