LEFT JOIN IN BigQuery Syntax error: Expected end of input but got keyword ON at [7:1]

Viewed 23918

I am attempting a two left joins for on order_revenue_delta_history on comcat_product_d and sales_location_d. I keeping getting the Syntax error: Expected end of input but got keyword ON at [7:1]. I tried putting it in (), and adding AND after b. so im not sure what it is I am doing wrong. This is my code so far below. I haven't finished the filter yet which I wanted it to show quantity sold >=1. Just trying to get it to run. Am I doing the whole join wrong? I am trying to join multiple datasets.

SELECT
  a. ll_quantity_sold,
  b.product_type
FROM
  `slb-it-sp-valuecapture-prod.ods_vc.order_revenue_delta_history` a
LEFT JOIN `slb-it-sp-valuecapture-prod.ear_aa_108.comcat_product_d` b,
    `slb-it-sp-valuecapture-prod.ear_aa_108.sales_location_d` c
ON
  ( a.ll_product_id = b.product_id
    AND a.location_id = c.location_id )
GROUP BY
  product_type
LIMIT
  1000
1 Answers

Try the following.

your left join is incorrect. You cannot join tables all together on single on.

SELECT
  a.ll_quantity_sold,
  b.product_type
FROM
  `slb-it-sp-valuecapture-prod.ods_vc.order_revenue_delta_history` a
LEFT JOIN `slb-it-sp-valuecapture-prod.ear_aa_108.comcat_product_d` b
ON a.ll_product_id = b.product_id
LEFT JOIN  `slb-it-sp-valuecapture-prod.ear_aa_108.sales_location_d` c
ON a.location_id = c.location_id 
GROUP BY
  product_type
LIMIT
  1000
Related