In "Microsoft SQL Server 2016: Querying Data with Transact-SQL" episode "Combining Results with JOIN Part 3", Don Pezet makes a mistake at 22:48 and doesn't catch it. He's correcting error:
The column 'BusinessEntityID' was specified multiple times for 'sp'.
He correctly concludes that * is the source of his problem. * specifies s.BusinessEntityID and p.BusinessEntityID. Don decides to specify s.BusinessEntityID. That's not necessary! The top-level SELECT needs only p.FirstName, p.LastName, and s.TerritoryID from the nested SELECT.
-
nested INNER JOIN
-
Thank you for the feedback. Many times I am making and modifying queries on the fly to demonstrate a concept. Sometimes that results in sub-optimal queries and it looks like you encountered one of those. I will review the episode and see if it needs to be modified. Microsoft is in the process of updating their SQL certifications so we will likely be refilming a lot of this content later in the year.
Thanks again,
Don