I am using an external DB and I have 3 important columns: **user\_id, total\_score, score\_order**.

I would like to **get the total\_score of each user**.

All the scores are always recorded, so I only need the last one. For this I need to use the **score\_order** column.

This is what I am trying to do (using nested queries because I need to **combine ORDER BY and GROUP BY**):

```
SELECT * FROM (
    SELECT * FROM `table` ORDER BY score_order DESC
) AS tmp_table GROUP BY user_id

```

But I get the error:

> 
> '#1055 - Expression #1 of SELECT list is not in GROUP BY clause and
>  contains nonaggregated column 'tmp\_table.ranking\_id' which is not
>  functionally dependent on columns in GROUP BY clause; this is
>  incompatible with sql\_mode=only\_full\_group\_by Can someone explain what
>  I am doing wrong?'
> 
> 
>