From the course: Database Foundations: Intro to Databases
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Aggregate data with GROUP BY
From the course: Database Foundations: Intro to Databases
Aggregate data with GROUP BY
- It's not uncommon for many of your data rows to contain the same value. For instance this query here that takes the CategoryDescription from a categories table, and the SQL column from the product table. when I run it I get all of my unique skills from the database and the categories that they belong to. There are olive oils, flavor infused oils, and if I scroll through the list you'll see some products in a Bath and Beauty category. And there's a few right there. When you have repeating values like this , you can group all the rows together, that have the same value. And then perform some aggregate calculations on the group. First, we need to tell the server that I want to collect all of the rows with the same CategoryDescription together. We do that with a GROUP BY clause added to the end of the query. We move this down and I want to go here on my number 9, I'm still going to move that semi-QL down the row. 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.