Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
年をグループ化し、各年の平均で過去 5 年間を選択して、平均と年の出力を取得する必要があります
SELECT AP, yr FROM ( SELECT Year AS yr, AVG( "tbltest.AskingPrice" ) AS AP FROM tbltest GROUP BY `yr` DESC LIMIT 5 )sub GROUP BY `yr` ASC
あなたのサブクエリはあなたが望むことをすると思います:
SELECT Year AS yr, AVG( "tbltest.AskingPrice" ) AS AP FROM tbltest GROUP BY `yr` ORDER BY Year DESC LIMIT 5;
標準 SQL との一貫性を保つためdescに、をに移動しました。order by
desc
order by