I have a table which looks like this:
record no firstType secondtype win?
1 X A 1
2 X A 0
3 X B 1
4 Y B 0
5 Y B 1
6 X B 1
7 X B 1
and what I need output is this.
firstType secondType winCounts
X [A,B] [A:1,B:3]
Y [B] [B:1]
So notice how the arrays under secondType tell where they OCCURED with firstType, while the arrays under winCounts tell how many wins of each secondType came with each firstType.
I can make the arrays using ARRAY_AGG but I'm lost for any possible way to make the winCounts column.