Home > OS >  BigQuery TPC-H Query 13 does not parse correctly
BigQuery TPC-H Query 13 does not parse correctly

Time:01-03

I have being trying TPC-H in BigQuery, all queries works out of the box, except Query 13

SELECT
  c_count,
  COUNT(*) AS custdist
FROM (
  SELECT
    c_custkey,
    COUNT(o_orderkey)
  FROM
    test-187010.TPCH.customer
  LEFT OUTER JOIN
    orders
  ON
    c_custkey = o_custkey
    AND o_comment NOT LIKE '%special%requests%'
  GROUP BY
    c_custkey) AS c_orders (c_custkey,
    c_count)
GROUP BY
  c_count
ORDER BY
  custdist DESC,
  c_count DESC;

I am getting this error Expected end of input but got "(", it is referring to (c_custkey, how to fix that thanks

CodePudding user response:

Try below instead

SELECT
  c_count,
  COUNT(*) AS custdist
FROM (
  SELECT
    c_custkey,
    COUNT(o_orderkey) as c_count
  FROM
    test-187010.TPCH.customer
  LEFT OUTER JOIN
    orders
  ON
    c_custkey = o_custkey
    AND o_comment NOT LIKE '%special%requests%'
  GROUP BY
    c_custkey) AS c_orders 
GROUP BY
  c_count
ORDER BY
  custdist DESC,
  c_count DESC;
  • Related