Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Query without FROM clause cannot have a WHERE clause

Hello, the error in the title occers every time and I would like to know how to solve.

My code is below.

SELECT
  date AS test_date,                                
  client.Geo.CountryName,                          
  a.MeanThroughputMbps.  
FROM
`measurement-lab.ndt.unified_downloads`
WHERE
client.Geo.CountryName IN ('Japan', 'United States', 'South Korea')

GROUP BY
  test_date, client.Geo.CountryName
ORDER BY
  test_date, client.Geo.CountryName
 
I checked the name of the files and the table, asked to ChatGPT, but it doesn't work.
I really need your help😭
0 3 190
3 REPLIES 3

You have a dot as a last character in the last column of your select clause "a.MeanThroughputMbps."

It's treating the rest of your query as still part of the column name of a.MeanThroughputMbps.

Remove the dot and the query should work.

If you remove the . before the FROM, it may work.

Hi @nacchi,

Welcome to Google Cloud Community!

I agree with @mars124 and @mdideles; you may want to review their suggestions.

For additional insights, you might find the BigQuery documentation on on Standard SQL Query Syntax: SELECT List helpful. Here are some key points to consider:

  • SELECT Clause: Each expression in the SELECT list can include an alias using AS. In your case, the alias test_date for the date column is correct, but ensure that the date column exists in your table.
  • Column References: Always verify that column names are correctly referenced and free of syntax errors, such as extra dots or missing aliases, as others have mentioned.
  • Grouping: When using GROUP BY, ensure that all non-aggregated columns in the SELECT clause are included in the GROUP BY clause.

By reviewing these syntax rules in the documentation, you can better align your query structure and address potential issues.

I hope the above information is helpful.