Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SELECT statement in WHERE clause on BigQuery not working

I'm trying to run the following query on Google BigQuery:

SELECT SUM(var1) AS Revenue
FROM [table1]
WHERE timeStamp = (SELECT MAX(timeStamp) FROM [table1])

I'm getting the following error:

Error: Encountered "" at line 3, column 19. Was expecting one of:

Is this not supported in BigQuery? If so, would there be an elegant alternative?

like image 242
Sylvain Laporte Avatar asked Mar 21 '23 15:03

Sylvain Laporte


1 Answers

Subselect in a comparison predicate is not supported, but you can use IN.

SELECT SUM(var1) AS Revenue
FROM [table1]
WHERE timeStamp IN (SELECT MAX(timeStamp) FROM [table1])
like image 68
Jordan Tigani Avatar answered Apr 01 '23 00:04

Jordan Tigani