I have a following data that a 5 groups which has certain IDs. One ID can be a part of multiple groups. I would like to find in how many group each ID is in.
Group ID
101 15122862
101 15122185
101 15121215
101 15123122
101 15121046
202 15122610
202 15122185
202 15121215
202 15123122
202 15121046
303 15122610
303 15121312
303 15121215
303 15123122
303 15121046
303 15122610
303 15121312
303 15121638
303 15123122
303 15121046
404 15122610
404 15121312
404 15121638
404 15122185
404 15121215
404 15122610
404 15121312
505 15121638
Result:
Row Labels Count of Group
15121046 4
15121215 4
15121312 4
15121638 3
15122185 3
15122610 5
15122862 1
15123122 4
Grand Total 28
I did this excel but I want do it in snowflake
I tried to use
Select ID, COUNT(Group)
FROM _Database
but it says not a valid group by expression.
Any help/suggestion would be appreciated.
Thank you!
I tried to use
Select ID, COUNT(Group)
FROM _Database
and expecting
Row Labels Count of Group
15121046 4
15121215 4
15121312 4
15121638 3
15122185 3
15122610 5
15122862 1
15123122 4
Grand Total 28
but it says not a valid group by expression.
RK03 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.