简体   繁体   English

错误1054。MySQL中“ on子句”中的未知列

[英]Error 1054. Unknown column in 'on clause' in MySQL

I have 2 tables in dataset: price change and built_used_area. 我在数据集中有2个表:价格变化和built_used_area。

I need to calculate average price change (from 1st table) over built_area (from second) for specific observations. 我需要针对特定​​观察值,计算Built_area(第二个)上的平均价格变化(从第一个表开始)。

I tried this query, but it didnt work. 我尝试了此查询,但没有成功。

select (avg((new_price-old_price)/old_price))/built_area from 
    (select * from price_change where year(change_date)=2016 and new_price > old_price) as T
    join built_used_area on (price_change.listing_id = built_used_area.listing_id);

Any ideas how to fix this? 任何想法如何解决这一问题?

Thanx for you help in advance. 感谢您的帮助。

solved with: 解决:

SELECT 
    AVG(new_price / built_area)
FROM
    (SELECT 
        new_price, built_area, change_date
    FROM
        price_change, built_used_area
    WHERE
        YEAR(change_date) = 2016
            AND new_price > old_price
            AND new_price > 0
            AND old_price > 0
            AND (built_area > 200 OR used_area > 200)) AS T;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM