我不斷遇到問題。我需要得到的是前3個AVG率最高的國家。SQL幫助:查詢問題
SELECT TOP 3
Country, AVG(AverageRate) AS 'AverageRate'
FROM
dbo.CountryOrders
WHERE
OrderDate BETWEEN '2011-01-01' AND '2011-12-31'
GROUP BY
Country
ORDER BY
'AverageRate' DESC;
GO
有什麼問題? – Joe
您的數據庫是否支持「TOP 3」? – qqilihq
在sql server 2005/2008'ORDER BY'不能看到別名。 – Mihai