Hesseltje van Goor
06/19/2023, 11:43 AMSELECT COUNT(*Id (CRM deals)*)
but this doesn't seem to stay static per applicant, which is what I am trying to get to.Michal Hauzírek
06/19/2023, 11:54 AMSELECT COUNT(Id (CRM deals)) WHERE (SELECT COUNT(Id (CRM deals)) BY email, ALL OTHER) = 1
Here the inner SELECT (especially the "BY email, ALL OTHER") makes sure it will count Ids BY user and nothing else and use this calculation for the filtering no matter what other attributes you use in your insight.Hesseltje van Goor
06/20/2023, 9:27 AMHesseltje van Goor
06/20/2023, 9:39 AMMichal Hauzírek
06/20/2023, 9:46 AMHesseltje van Goor
06/20/2023, 9:49 AMSELECT COUNT(Id (CRM deals)) WHERE (SELECT COUNT(Id (CRM deals)) BY Email) = 1
Hesseltje van Goor
06/20/2023, 9:50 AMHesseltje van Goor
06/20/2023, 9:50 AMHesseltje van Goor
06/20/2023, 9:50 AMHesseltje van Goor
06/20/2023, 9:50 AMHesseltje van Goor
06/20/2023, 9:52 AMHesseltje van Goor
06/20/2023, 9:52 AMHesseltje van Goor
06/20/2023, 9:53 AMHesseltje van Goor
06/20/2023, 9:53 AMHesseltje van Goor
06/20/2023, 9:54 AMHesseltje van Goor
06/20/2023, 9:54 AMHesseltje van Goor
06/20/2023, 9:54 AMALL OTHER
mean? It wasn't working before I added this in.Michal Hauzírek
06/20/2023, 11:32 AMid
by email
and lost reason
. Let’s assume this data:
id, email, lost reason
1, john, too early
2, john, too early
3, pete, too early
4, pete, unavailable
And now we can have four metrics:
• simple SELECT COUNT(id)
with split the data based on what attributes you use in the insight
• SELECT COUNT(id) BY email ALL OTHER
will only be split by email but no other attribute (not lost reason in this case). And the value of count id by email will get repeated for all values of all other attribtues.
• SELECT COUNT(id) BY lost reason ALL OTHER
is equivalent, just it splits data only by lost reason and not anything else
• and the extreme case is SELECT COUNT(id) BY ALL OTHER (without any attribute mentioned) - that means we do not want to split the value by any attribute ever - so it is total overall number of ids and this value is repeated for every single value of any attribute
◦ this one might be useful for example to calculate percentage of total if you ever wanted that i.e. SELECT COUNT(id) / (SELECT COUNT(id) BY ALL OTHER)
Hesseltje van Goor
06/20/2023, 3:19 PMid, email, lost reason
1, john, too early
2, john, too early
3, pete, too early
4, pete, unavailable
• SELECT COUNT(id)
- the number of tickets (id) that each email has per lost reason. John has 2 tickets that are too early. Pete has 1 ticket that is too early. Pete has 1 ticket that is unavailable.
• SELECT COUNT(id) BY email ALL OTHER
- the number of tickets per email. John and Pete made two requests each, so this is 2 each time.
• SELECT COUNT(id) BY lost reason ALL OTHER
- the number of tickets per lost reason. There are 3 tickets that are too early, and 1 ticket that is unavailable.
• SELECT COUNT(id) / (SELECT COUNT(id) BY ALL OTHER)
- the number of tickets that each email has per lost reason, divided by the number of tickets that exist in the database in total. So this becomes 50%, 25%, 25% for this table.
Question, how would you deal with a situation like this?
id, email, lost reason
1, john, <no data>
2, john, too early
3, pete, too early
4, pete, unavailable
5, andrew, <no data>
Let's say I wanted to know the number of users who have a ticket with a lost reason that isn't empty. How would I write a query that excludes Andrew but includes John? (i.e. a query that returns 2, as John has a ticket with a lost reason that isn't empty, even though he also has a ticket where the lost reason is empty)Michal Hauzírek
06/20/2023, 5:56 PMSELECT COUNT(user) WHERE lost reason<>(empty value)
This will filter out rows 1 and 5 and then counts distinct number of users in the remaining rows so should give you 2 (john and pete).