From the course: Advanced SQL: Logical Query Processing, Part 1
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Grouped query with Distinct - SQL Tutorial
From the course: Advanced SQL: Logical Query Processing, Part 1
Solution: Grouped query with Distinct
- [Instructor] Like before, I always start with a from clause and first join all the tables I think I'll need with an inner join as a starting point, alias them, add the qualification predicate and execute a quick select star, just to make sure I didn't miss anything obvious and that the query executes. Since I need to include animals that were never vaccinated, I'll change the join to a left outer and now I'll also add an order by for good measures and execute it again. I know we have animals that were not vaccinated so it's a good idea to make sure I can see some rows with no for vaccination attributes and it looks good so far. Now I can attend to the select expressions and start with the ones I already have available. From the animals table, I can get name, species, primary color and breed. And from the vaccination table, I can get vaccine. Now we can move on to the grouping. I know we need to return one row per animal…
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.