Created
May 4, 2023 06:34
-
-
Save agehlot/ae04e57b95f8023967f4390c63f39a04 to your computer and use it in GitHub Desktop.
CDP SQL query that selects customers where the sum of all their order totals is greater than 100
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 partners_sandbox.orders | |
where upper(partners_sandbox.orders.type) = upper('STANDARD') | |
group by meta_guest_ref | |
having SUM(partners_sandbox.orders.core_price) > 100.0) as o | |
inner join partners_sandbox.guests as g | |
on o.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