I am a newbie
I using firebase events to track what my user are doing on my website.
As a simple example my "happy" use case is a user completes steps A, B, C. I want to count the number of user that have are Happy or not Happy. Not happy is defined as their session does not contain all three events
Here is my sample SQL with some simple data. I am able to to count the number of "C" events in the happy sessions. I can not figure out how to identify sessions that are not Happy
WITH testData AS ( SELECT "id1" as idd, "A" as name UNION ALL SELECT "id1" , "B" UNION ALL SELECT "id1" , "C" UNION ALL SELECT "id2" , "A" UNION ALL SELECT "id2" , "B" UNION ALL SELECT "id3" as id, "A" as name UNION ALL SELECT "id3" , "B" UNION ALL SELECT "id3" , "C" UNION ALL SELECT "id4" , "A" UNION ALL SELECT "id4" , "B" UNION ALL SELECT "id5" , "A" UNION ALL SELECT "id5" , "B" UNION ALL SELECT "id5" , "C" UNION ALL SELECT "id5" , "A" UNION ALL SELECT "id5" , "B" UNION ALL SELECT "id5" , "C" ) SELECT * FROM (SELECT idd, COUNT(name) as PASSED FROM testData where name = "C" GROUP BY idd) UNION ALL (SELECT idd, NUMERIC '0' as PASSED FROM testData where name != "C" GROUP BY idd) ORDER BY idd Row idd PASSED 1 id1 1 2 id1 0 3 id2 0 4 id3 1 5 id3 0 6 id4 0 7 id5 2 8 id5 0
I was expecting the results to be something like
Row idd PASSED 1 id1 1 3 id2 0 4 id3 1 6 id4 0 7 id5 2
Any suggestions would be greatly appreciated.
Also can anyone suggest a really good advanced SQL tutorial?
Andy