“仅显示前两座建筑及其相应的平均值
会话的价格。”
任何帮助都是非常感谢的,我已经尝试了很多年了,这是我迄今为止最好的尝试…

SELECT BUILDINGNO.BUILDING, AVG(SESSIONPRICE.CONFERENCESESSION)
FROM BUILDING
JOIN CONFERENCESESSION ON BUILDINGNO.BUILDING = BUILDINGNO.CONFERENCESESSION
WHERE BUILDINGNO.BUILDING = SESSIONPRICE.CONFERENCESESSION
GROUP BY BUILDINGNO.BUILDING
Order by BUILDINGNO.BUILDING DESC;

干杯

最佳答案

你可以用这个。

SELECT TOP 2  BUILDINGNO.BUILDING, AVG(SESSIONPRICE.CONFERENCESESSION)
FROM BUILDING
JOIN CONFERENCESESSION ON BUILDINGNO.BUILDING = BUILDINGNO.CONFERENCESESSION
WHERE BUILDINGNO.BUILDING = SESSIONPRICE.CONFERENCESESSION
GROUP BY BUILDINGNO.BUILDING
Order by AVG(SESSIONPRICE.CONFERENCESESSION) DESC;

关于sql - 查找多行的平均值并显示最高的AVG,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46592698/

10-10 04:20