课程: SQL Hands-On Practice: Solve Business Problems
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Solution: Employee-manager data with a self join - SQL教程
课程: SQL Hands-On Practice: Solve Business Problems
Solution: Employee-manager data with a self join
- [Instructor] Now that you've had a chance to work on this problem, can you see the similarities between this one and the intro problem of this chapter? This problem also requires self joining the employees table to itself. However in this problem, we're pulling different fields and filtering the data set. This means we have to really pay attention to which tables we're pulling the fields from and filtering with. It can get really tricky with self joins because both tables have the same column names, but you can't use them interchangeably because of the relationship you defined in the join. Let's start with joining the employees table to itself just as we did in the intro. We'll let the first table represent employees and the second table represent managers since it's joined on the manager ID of the first table. We're going to start out with select and then we're going to use star as a placeholder, but we're going to…