From the course: SQL Server Fundamentals: Master Basic Query Techniques
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Solution: Inner joins
From the course: SQL Server Fundamentals: Master Basic Query Techniques
Solution: Inner joins
(upbeat music) - [Instructor] In this solution, I need to get access to data from a couple different tables. So I'm going to start by writing my join conditions. We'll add a table alias for Orders, and then INNER JOIN to the Customer table AS c. And then our join condition here is going to be the CustomerId, since those are shared in both tables. And then we're going to add the Salesperson table as well AS s on the SalespersonID from the Orders table and the Salesperson table. Now I can add my filtering. I know I only want orders where the Status = past due and the Salesperson, so s, LastName = Hall. So now that I have the correct data set, I'm going to specify which columns I want. So I need the OrderId. And then to get the customer name, I'm going to use the CONCAT function to combine the FirstName, make sure I include a space so those values don't get squished together, the LastName, and then give that column alias of CustomerName. I also need the customer's Email, the TotalDue…
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.