From the course: Advanced SQL: Logical Query Processing, Part 2
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Lateral joins - SQL Tutorial
From the course: Advanced SQL: Logical Query Processing, Part 2
Lateral joins
- [Instructor] One of the limitation of joins is that each table expression that's being joined must stand alone and be independent of any other. So this query is valid. Each table expression is complete and independent. But if we introduce a correlation between the two, we're going to get an error. F1 Bar is an unknown expression. And the reason is that it does not exist in the context of the sub query. Introducing such correlations could have been very useful for several types of challenges. And the most common one is known as the top end per group challenge. We need to show all animals with their most recent vaccination. Let's start with the animal attributes, names, species, color, and breed, and all that's missing is the last vaccine. I often see developer use correlated expression sub-queries for these types of challenges. Select vaccine from vaccinations. Predicate for the same animal, and add a limit to the…
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.