I'm new to SQL and using Google BigQuery. I have a table with one record that looks like the following:
publication_number | assignee
US-6044964-A|Sony Corporation
|Digital Audio Disc Corporation
The identifier, publication_number, is listed only once; the first assignee appears on the same row as the publication_number and the second just shows up as an additional row with no identifier.
What I want to do is create a table like the following:
publication_number | assignee1 | assignee2
US-6044964-A | Sony Corporation |Digital Audio Disc Corporation
Where the additional assignee appears as another column.
I have what Google's patents-public-data calls a "repeated" variable. I've tried the following query in BigQuery:
SELECT pvt.publication_number, pvt.[1] as assignee1, pvt.[2] as assignee2
FROM `main_tables.main_table5`
PIVTO (
MAX(assignee)
FOR publication_number IN([1],[2])
) as pvt
I receive the following error:
Syntax error: Unexpected "[" at [2:36]. If this is a table identifier, escape the name with
, e.g.
table.name` rather than [table.name]
I have found the following question/reply that does something similar to what I want using pivot here. However, I don't have an identifier for each row as in that example.
How can I create another column for the second assignee?