I have a relational dataset in Bigquery containing two tables.
The first table holds customer data
+-------------+--------+
| Customer ID | Name |
+-------------+--------+
| 1 | Bob |
+-------------+--------+
| 2 | Jenny |
+-------------+--------+
| 3 | Janice |
+-------------+--------+
The second table holds various name/value pairs associated to the customer in first table:
+-------------+----------+-------+
| Customer ID | Category | Value |
+-------------+----------+-------+
| 1 | A | A |
+-------------+----------+-------+
| 1 | A | B |
+-------------+----------+-------+
| 1 | B | A |
+-------------+----------+-------+
| 2 | B | B |
+-------------+----------+-------+
I would like to generate a report that enumerates each customer, and sets a TRUE under each name:value where it is found in table 2 e.g:
+-------------+------+------+-----+------+------+
| Customer ID | A:A | A:B | A:C | B:A | B:B |
+-------------+------+------+-----+------+------+
| 1 | TRUE | TRUE | | TRUE | |
+-------------+------+------+-----+------+------+
| 2 | | | | | TRUE |
+-------------+------+------+-----+------+------+
| 3 | | | | | |
+-------------+------+------+-----+------+------+
I've tried to specify each of the category:value combinations as columns in my select statement
select
customer id,
a:a,
a:b,
a:c,
b:a,
b:b
from
table_1 t1
join
table_2 t2
on
t1.customer_id = t2.customer_id
But that gives me nothing because I don't know how to get the query to set a cell to TRUE, once the value is found.
Apologies if this is obvious, i'm painfully new to SQL.