我需要編寫一個涉及子查詢和索引的查詢。所以,我想出了一個查詢,發現其具有最高的積累速度在一年中的隊名:在MySql Workbench中對索引查詢
SELECT CONCAT(team_long_name, ',', team_short_name) AS TeamName,
EXTRACT(YEAR FROM date) AS Year,
buildUpPlaySpeed
FROM team JOIN
team_attributes
ON team.team_api_id = team_attributes.team_api_id
WHERE
(buildUpPlaySpeed,team_attributes.date) in (SELECT
MAX(buildUpPlaySpeed),team_attributes.date
FROM team_attributes
WHERE team_attributes.date = team_attributes.date
group by team_attributes.date)
ORDER BY date desc;
指標上存在日期,team_api_id,buildUpPlaySpeed列。
關於如何進一步降低成本的任何建議?
羅恩,似乎你可能會很新的#1。如果問題已得到解答,您需要指出是哪個答案,即您「接受」答案。要接受「[**點擊Tick **](https://ibb.co/ikqyO6)」以獲取更多信息,請參閱[幫助/接受](https://stackoverflow.com/help/someone-answers) –