From the course: Learning SQL Programming

Unlock the full course today

Join today to access over 23,100 courses taught by industry experts.

Solution: Practice with JOINs

Solution: Practice with JOINs - SQL Tutorial

From the course: Learning SQL Programming

Solution: Practice with JOINs

- [Instructor] To solve this challenge, we need to use information from both of the tables in our database. So here in the middle of the query, I'm using a join statement. And then with on, I'm saying that the state_abbreviation field on the states table corresponds with the state_code field on the people table. So that's how we'll connect the tables and use them both at the same time. In the SELECT statement, I'm using the region field from the states table because the challenge asked us for the region, and I'm using the team field from the people table because we also need to consider the teams when we're counting up the number of people on each team in each region. The last value here is a count of members of the team on the people table. These are the fields we want, but we need to add a GROUP BY clause to actually have them be used the way that the challenge requires. In the GROUP BY clause, I'll use the…

Contents