From the course: Learning SQL Programming

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Solution: Retrieve data from the database

Solution: Retrieve data from the database - SQL Tutorial

From the course: Learning SQL Programming

Start my 1-month free trial

Solution: Retrieve data from the database

(upbeat music) - [Instructor] To solve this challenge, this is the query that I wrote. When I run it, we can see that all of the people who wanted a hat are grouped together here. And as I scroll down, we can see that there's the Angry Ants and the Baffled Badgers and the Cosmic Cobras. These participants are grouped first by what souvenir they wanted and then by their team. And when the list of people who want hats is done, we see the people who want shirts. This list is organized in the way it needs to be and it shows the information that our souvenir manufacturer needs. Hopefully your solution looks like this too. The key here is to use the order by keyword and to provide it two fields to sort the data by. But it's also important to use the names of the fields we need to see in the select statement too. An asterisk would get us all these fields, but it would also include other fields that aren't relevant. So targeting…

Contents