Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Given the following table
- customer product
- +---------------+---------+ +---------------+---------+
- | id | int |-----+ +--| id | int |
- | age | int | | | | price | double |
- | gender | char | | | +---------------+---------+
- +---------------+---------+ | |
- | | sale
- | | +---------------+---------+
- | | | id | int |
- | +->| product_id | int |
- +---->| customer_id | int |
- +---------------+---------+
- */
- /**
- * 1. Get the total revenue for all males in the customer database.
- *
- *
- */
- # select * from customer limit 10;
- select sum(p.price)
- from customers c left outer join sales s
- on c.id = s.customer_id
- left outer join products p
- on s.product_id = p.id
- where c.gender = 'm';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement