user3131691
user3131691

Reputation: 21

error query mysql on pentaho data integration (cdb)

mysql query is :

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

but it's doesn't work and this is error message

#1054 - Unknown column 'dim_location.sk_location' in 'on clause'

Upvotes: 2

Views: 208

Answers (1)

RGO
RGO

Reputation: 4727

Please re-order the tables in the FROM clause as in the query given below; otherwise, the join condition in the ON clause that is meant to be applied to joining the dim_location and fact_flight tables, will be wrongly applied to the dim_date and fact_flight tables which would result in the above error:

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

Upvotes: 1

Related Questions