I’m trying to create a temp table in BigQuery, something like:
CREATE TEMP TABLE myTmpTable AS SELECT t.event_id, MAX(t.event_date) FROM eventsTable t WHERE t.field_name = "foo" AND t.new_string = "bar" GROUP BY t.event_id;
This results in error “CREATE TABLE columns must be named, but column 2 has no name”. I understand that it can’t extract a column name from MAX(t.event_date). Is there a way I can specify a column name?
Advertisement
Answer
Is there a way I can specify a column name?
Use below
SELECT t.event_id, MAX(t.event_date) AS max_event_date
Meantime the whole SELECT looks wrong to me – if you group by issue_id then event_id should be somehow aggregated. Or you might want to group by event_id instead!