From the course: Database Foundations: Intro to Databases
Unlock the full course today
Join today to access over 25,000 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…
Contents
-
-
-
-
-
-
-
-
- (Locked) Display column aliases with AS4m 59s
- (Locked) Mathematical operations3m 20s
- (Locked) Use built-in functions5m 51s
- (Locked) Aggregate data with GROUP BY3m 34s
- (Locked) Filtering groups with HAVING3m 13s
- (Locked) Challenge: Query data1m 3s
- (Locked) Solution: Query data9m 39s
- (Locked) Solution: Query summary statistics6m 57s
- (Locked)
-