From the course: SQL for Non-Programmers
Unlock the full course today
Join today to access over 23,400 courses taught by industry experts.
Solution: Multiple table joins solved - SQL Tutorial
From the course: SQL for Non-Programmers
Solution: Multiple table joins solved
You were tasked with pulling an olive oil product sales report split by region. An additional version of this report is needed, including only business customers. I have chosen to first solve this using an inner join. In that case, your first query should look like this. We'll start out by selecting the columns we need. SELECT r.region, comma. Next line. SUM s.order total as total sales. I'm using aliases R and S, which are assigned to the tables that we're pulling from. Then we're going to go to the next line and specify the tables that we need. And we're going to use an inner join to connect them. FROM oliveoil.regions as r INNER JOIN oliveoil.sales as s. How can we join these tables? What is their common key? It's state. So on the next line, we can add on r dot state equals s dot customer state. We'll also add a filter for only the olive oil product category. WHERE s product category equals olive oil. And finally, let's group our data and put some order to it. GROUP BY r dot…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.