From the course: MySQL Data Analysis
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Multiple dimension GROUP BY clauses - MySQL Tutorial
From the course: MySQL Data Analysis
Multiple dimension GROUP BY clauses
- [Instructor] All right, the next thing we're going to do is show you how to GROUP BY multiple dimensions at the same time. You can use GROUP BY with multiple columns by listing those columns and separating them with a comma. This lets you create groups and subgroups in your result set. For Excel users, you'll realize this is very similar to doing PivotTables with multiple row or column labels. My pro tip for multiple GROUP BY is to think about your dimensions and trending them over time. For example, you may have a certain customer segment and you may want to create monthly or weekly trends. You can do this by first grouping by customer segment, and then grouping by whatever time dimension you're interested in. Here's how the query syntax looks. You see we've got a SELECT with two dimensions, and then one aggregate function as our metric. And we see those two dimensions appear in the GROUP BY. Notice how the dimensions are separated with commas the same way we do when we grab…
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.
Contents
-
-
-
-
(Locked)
Introduction24s
-
(Locked)
Getting to know the database3m 52s
-
(Locked)
The Big 62m 18s
-
(Locked)
The SELECT statement47s
-
(Locked)
The FROM clause39s
-
SELECT * FROM6m
-
(Locked)
The USE statement3m 19s
-
(Locked)
Selecting specific columns4m 18s
-
(Locked)
Challenge: SELECT and FROM1m 24s
-
(Locked)
Solution: SELECT and FROM2m 38s
-
(Locked)
SELECT DISTINCT2m 13s
-
(Locked)
Challenge: SELECT DISTINCT38s
-
(Locked)
Solution: SELECT DISTINCT2m
-
(Locked)
The WHERE clause1m 30s
-
(Locked)
Common WHERE operators4m 59s
-
(Locked)
Challenge: The WHERE clause35s
-
(Locked)
Solution: The WHERE clause2m 23s
-
(Locked)
Combining WHERE and AND4m 22s
-
(Locked)
Challenge: WHERE and AND39s
-
(Locked)
Solution: WHERE and AND1m 37s
-
(Locked)
Combining WHERE and OR3m 38s
-
(Locked)
Challenge: Combining WHERE and OR42s
-
(Locked)
Solution: Combining WHERE and OR3m 21s
-
(Locked)
Combining WHERE and IN4m 35s
-
(Locked)
The LIKE operator2m 37s
-
LIKE wildcard examples5m 6s
-
(Locked)
Challenge: The LIKE operator30s
-
(Locked)
Solution: The LIKE operator2m 28s
-
(Locked)
The GROUP BY clause1m 43s
-
(Locked)
GROUP BY example3m 18s
-
(Locked)
Pro Tip: Using comments and aliases5m 32s
-
(Locked)
Challenge: GROUP BY37s
-
(Locked)
Solution: GROUP BY2m 1s
-
(Locked)
Multiple dimension GROUP BY clauses3m 14s
-
(Locked)
Aggregate functions2m 8s
-
(Locked)
Challenge: Aggregate functions55s
-
(Locked)
Solution: Aggregate functions3m 23s
-
(Locked)
The HAVING clause1m 44s
-
(Locked)
HAVING example2m 54s
-
(Locked)
Challenge: The HAVING clause54s
-
(Locked)
Solution: The HAVING clause3m 11s
-
(Locked)
The ORDER BY clause1m 31s
-
(Locked)
ORDER BY example4m 16s
-
(Locked)
Challenge: The ORDER BY clause30s
-
(Locked)
Solution: The ORDER BY clause1m 47s
-
(Locked)
Recap: The Big 62m 8s
-
(Locked)
-
-
-
-