'Get Syntax Error: Expected end of input but got keyword ORDER at [5:1]: in BigQuery

When I run the following I get the error Syntax Error: Expected end of input but got keyword ORDER at [5:1]:

SELECT purchase_price FROM test-project-349410.customer_data.customer_purchase LIMIT 1000 ORDER BY purchase_price DESC;

I have tried a semicolon after the project name, semicolon after DESC. This from the Google Data Analytics course and it was typed exactly as they presented in the video. Not sure how to make this run. Thanks for any help.



Solution 1:[1]

Reverse the LIMIT clause and the ORDER clause.

SELECT
  purchase_price
FROM 
  test-project-349410.customer_data.customer_purchase
ORDER BY purchase_price DESC
LIMIT 1000;

Deeper cut: If it's of interest to you, there's more details on SQL syntax in BigQuery at https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 shollyman