<分区>
我有这张表:
TABLE 优惠
+------+--------------+----------+----------------+
| 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 |
+------+--------------+----------+----------------+
我期待这样的结果, 我想创建一个这样的 View :
+------+--------------+----------+----------------+
| id | player_id | team_id | valore |
+------+--------------+----------+----------------+
| 1 | 1 | 1 | 230 |
| 3 | 9 | 3 | 150 |
| 6 | 7 | 1 | 38 |
+------+--------------+----------+----------------+
我尝试使用此 SQL 代码:
创建 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
但结果与第一个表相同......它没有改变任何东西。 谁能帮帮我?