Skip to content

Instantly share code, notes, and snippets.

@flutesa
Created April 17, 2020 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flutesa/0f37e625cd150432e6065b2f1f145ad6 to your computer and use it in GitHub Desktop.
Save flutesa/0f37e625cd150432e6065b2f1f145ad6 to your computer and use it in GitHub Desktop.
select users.country, sum(orders.order_sum) as total_sum
from `DZ1.users` users
left join `DZ1.orders` orders
on orders.user_id = users.id
where users.country = 'Russia' or users.country = 'Brazil'
group by users.country
order by total_sum desc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment