Skip to content

Instantly share code, notes, and snippets.

@agehlot
Last active May 4, 2023 06:33
Show Gist options
  • Save agehlot/9d776876bf195cd1dfa10f9addb7b58f to your computer and use it in GitHub Desktop.
Save agehlot/9d776876bf195cd1dfa10f9addb7b58f to your computer and use it in GitHub Desktop.
This SQL can be used to aggregate fields covering sessions and events
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