mysql查询是:
SELECT
dim_location.country_name,
COUNT(fact_flight.sk_fact)
FROM
dim_location, dim_date
INNER JOIN fact_flight ON dim_location.sk_location = fact_flight.sk_location
WHERE
fact_flight.date_key = dim_date.date_key
GROUP BY
dim_location.country_name
但它不起作用,这是错误信息
#1054 - Unknown column 'dim_location.sk_location' in 'on clause'
答案 0 :(得分:1)
请按照下面给出的查询重新排序FROM子句中的表格;否则,ON子句中用于加入dim_location
和fact_flight
表的连接条件将被错误地应用于dim_date
和fact_flight
表会导致上述错误:
SELECT
dim_location.country_name,
COUNT(fact_flight.sk_fact)
FROM
dim_date, dim_location
INNER JOIN fact_flight ON dim_location.sk_location = fact_flight.sk_location
WHERE
fact_flight.date_key = dim_date.date_key
GROUP BY
dim_location.country_name