I have two tables, stats and stat\_log. The stat log is like this:

`user_id,stat_id,value,registered` 

and It logs the value of the stats for the given times. I need every last value from every stat for a given user.

So i want something like this, but with values:
`select stat,max(registered) from stat_log where uid = 1 group by stat;` 

```
 stat |    max       
------+------------  
    6 | 2009-10-08  
    1 | 2009-10-08  
    3 | 2009-10-08  
    5 | 2009-10-08  
    7 | 2009-10-08  
    4 | 2009-10-08  

```

Instead I've got this:

`select stat,max(registered),value from stat_log where uid = 1 group by stat,value;`

```
 stat |    max     | value   
------+------------+-------  
    4 | 2009-10-08 | 38  
    5 | 2009-10-08 | 118  
    1 | 2009-10-08 | 100  
    1 | 2009-10-07 | 101  
    6 | 2009-10-08 | 68  
    3 | 2009-10-08 | 110    
    7 | 2009-10-08 | 53

```

What's the correct query? This is PostgreSQL 8.3.