0

我的查询需要更多时间来提供输出,我可以创建可以轻松输出的查询吗?

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
4

1 回答 1

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
于 2012-06-28T14:57:50.723 回答