Hey I am trying to transform a table from this:
Into this:
Basically for each "Type" I want the totals for the different values for "Exists" which right now is just TRUE and FALSE.
But I can only get to this so far:
I did that using the following QUERY
SELECT B, C, COUNT(C) GROUP BY B,C
I know the next step requires a PIVOT
but I'm having some fundamental misunderstanding about how PIVOT
works to get anywhere. If you could help me out with some understanding and not just give me the answer it would be great.
Best Answer
The select argument of QUERY doesn't allow to use the same column to group, aggregate and to pivot data.
The workaround is to add an auxiliary column that repeats the data from C, let say it will be D, the select argument will be