BigQuery unexpected keyword

14,938

You have a few syntax errors, namely the limit 10 in the wrong place, and using the HAVING keyword incorrectly. I'd also use native timestamp instead of comparing strings:

#standardSQL
SELECT
  title,
  body,
  answer_count,
  creation_date,
  tags,
  view_count
FROM
  `bigquery-public-data.stackoverflow.posts_questions`
WHERE
  creation_date >= TIMESTAMP('2015-01-01')
  AND tags IN ('terraform',
    'chef',
    'puppet',
    'ansible')
LIMIT
  10
Share:
14,938
Cloud Noob
Author by

Cloud Noob

Updated on June 04, 2022

Comments

  • Cloud Noob
    Cloud Noob almost 2 years

    I'm just getting started with Google BigQuery, and have run into issues with my very first query. I'm trying to get a list of Stack Overflow posts since and including 2015-01-01 which have one of several tags. Below is my first pass at the query:

    #standardSQL
    
    SELECT
     title,
     body,
     answer_count,
     creation_date,
     tags,
     view_count 
    
    FROM
     `bigquery-public-data.stackoverflow.posts_questions` limit 10
    
    WHERE
     creation_date >= "2015-01-01" AND tags HAVING "terraform" OR "chef" OR "puppet" OR "ansible"
    

    The BigQuery validator is showing the following error message:

    Error: Syntax error: Unexpected keyword WHERE at [14:1]