Hajar Homayouni
Hajar Homayouni

Reputation: 590

Join with <= in the On clause in Google bigquery

I want to execute a query with join in Google bigquery that has '<=' instead of '=' in it's on clause:

select s.count_value as count_value,s.total as total,sum(p.total) as accumulated    from  stats s   join stats p on p.rn <=s.rn   group by count_value,total,s.rn

When I run this query, I receive an error message saying:

Error: ON clause must be AND of = comparisons of one field name from each table, with all field names prefixed with table name.

Any idea how I can implement this query?

Upvotes: 2

Views: 248

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173013

You should enable Standard SQL to do such JOINs
See Enabling Standard SQL

in CLI - just add the --use_legacy_sql=false flag to your command line statement.

Upvotes: 3

Related Questions