Last active
May 4, 2023 06:33
-
-
Save agehlot/9d776876bf195cd1dfa10f9addb7b58f to your computer and use it in GitHub Desktop.
This SQL can be used to aggregate fields covering sessions and events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select g.meta_ref as guest_ref | |
from (select meta_guest_ref | |
from sandbox_tenant_06.sessions as s | |
inner join (select * from sandbox_tenant_06.events where upper(sandbox_tenant_06.events.type) = upper('POINTSCOLLECTED')) as e | |
on s.meta_ref = e.meta_session_ref | |
group by s.meta_guest_ref | |
having SUM(cast(e.ext['points'] as double)) > 20) as j | |
inner join sandbox_tenant_06.guests as g | |
on j.meta_guest_ref = g.meta_ref | |
group by g.meta_ref |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment