Created
November 16, 2017 13:04
-
-
Save AndreyBespamyatnov/09dad7f0350e15bffcb2652d2644eb77 to your computer and use it in GitHub Desktop.
This file contains 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
-- a- list of clients, which have an order with order_sum > 50 | |
select c.client_id, c.client_name from Clients as c | |
inner join Orders as o on o.client_id = c.client_id | |
where o.order_sum > 50 | |
-- b- clients, whose total sum of orders exceeds 100 | |
Select * from | |
(select c.client_id, c.client_name, SUM(o.order_sum) as total from Clients as c | |
inner join Orders as o on o.client_id = c.client_id | |
GROUP BY c.client_id) as t | |
where total > 100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment