I have this table:
TABLE offers
+------+--------------+----------+----------------+
| id | player_id | team_id | valore |
+------+--------------+----------+----------------+
| 1 | 1 | 1 | 230 |
| 2 | 1 | 3 | 150 |
| 3 | 9 | 3 | 150 |
| 4 | 1 | 5 | 100 |
| 5 | 7 | 5 | 37 |
| 6 | 7 | 1 | 38 |
+------+--------------+----------+----------------+
And I expect this results, I would like to create a view like this:
+------+--------------+----------+----------------+
| id | player_id | team_id | valore |
+------+--------------+----------+----------------+
| 1 | 1 | 1 | 230 |
| 3 | 9 | 3 | 150 |
| 6 | 7 | 1 | 38 |
+------+--------------+----------+----------------+
I try with this SQL CODE:
create view...
select t1.*
from offers t1
left join ( select player_id,
team_id,
max(valore) as valore
from offers
group by player_id,
team_id) t2
on t1.player_id = t2.player_id
and t1.team_id = t2.team_id
and t1.valore = t2.valore
But the results is the same of first table...It does not change anything. Can anyone help me?