rp346
rp346

Reputation: 7028

SQL to Bigquery

How do I convert following sql to bigquery

SELECT table1.field1, table2.field2, table2.field3, table2.field4, table2.field5, table2.field6, table2.field7 
FROM table1
JOIN EACH table2 on table1.cookie=table2.cookie 
GROUP BY table2.field3,table1.field1,table2.field2,table2.field4,table2.field5,table2.field6,table2.field7
WHERE table2.field3=1176;

I am getting following error " Encountered " "WHERE" "WHERE "" at line 2, column 1 "

Upvotes: 0

Views: 243

Answers (1)

GGio
GGio

Reputation: 7653

Your WHERE is in the wrong place. WHERE should be before GROUP BY and after the last JOIN or after FROM if there are no JOINS.

Try this:

SELECT table1.field1, table2.field2, table2.field3, table2.field4, table2.field5, table2.field6, table2.field7 
FROM table1 
JOIN EACH table2 on table1.cookie=table2.cookie 
WHERE table2.field3=1176;
GROUP BY table2.field3,table1.field1,table2.field2,table2.field4,table2.field5,table2.field6,table2.field7 

Upvotes: 3

Related Questions