SELECT
Lookup.DecadeID,
Data.*
FROM
(
SELECT
truncate(yearid/10,0) as decadeID,
MAX(HR) as Homers
FROM
masterplusbatting
GROUP BY
truncate(yearid/10,0)
)
AS lookup
INNER JOIN
masterplusbatting AS data
ON data.yearid >= lookup.decadeID * 10
AND data.yearid < lookup.decadeID * 10 + 10
AND data.HR = lookup.homers
Đã chỉnh sửa cho MySQL