My Query花费更多时间来提供输出,我可以创建可以轻松输出的查询。
SELECT DISTINCT(property.Project_Name), property.Property_Type, ROUND(AVG(property.Unit_Price_psf)), property.Transacted_Price
FROM property
JOIN avg_property
WHERE avg_property.Project_Name=property.Project_Name
AND avg_property.Median_Price BETWEEN '$mdpr1' AND '$mdpr2'
GROUP BY property.Project_Name
答案 0 :(得分:0)
重写distinct
的替代方案SELECT
property.Project_Name,
property.Property_Type,
ROUND(AVG(property.Unit_Price_psf)),
property.Transacted_Price
FROM property
JOIN avg_property
WHERE exists(select
Project_Name
from property
group by Project_Name)
and avg_property.Project_Name = property.Project_Name
AND avg_property.Median_Price BETWEEN '$mdpr1'
AND '$mdpr2'
GROUP BY property.Project_Name