I've got an database where every user has an uid, but can login with an different nickname each time (table A). Now the user can buy stuff and and I am saving the login id and the price (table B). I made an example, note that Nick and NickRenamed are the same person as they have the same uid

Table A

```
id  |  nickname   |  uid
1   | Nick        |  abcdef
2   | Nack        |  ab1234
3   | NickRenamed |  abcdef

```

Table B

```
id  |  idA  | price
1   |   1   |   200
2   |   1   |   400
3   |   2   |    20
4   |   3   |    75

```

For an statistic I want to get every (distinct) uid, the latest nickname and sum the price of this user

```
uid    | nickname    |  price_total
abcdef | NickRenamed |   675
ac1234 | Nack        |    20

```

My approch was 

```
SELECT DISTINCT(A.uid)
     , A.id
     , A.nickname
     , SUM(B.price) 
  FROM A 
  JOIN B 
    ON A.id = B.idA 
 GROUP 
    BY A.uid

```

but an error gets thrown 

```
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated 
column 'test.A.id' which is not functionally dependent on columns in 
GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

```