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.

GROUP BY example

GROUP BY example

- [Instructor] All right, we're going to talk about aggregating our data at the group level. We use GROUP BY, which allows us to perform segment-level analysis of our data instead of just extracting records. When we combine GROUP BY with aggregate functions, like COUNT or SUM, min or max, this becomes very powerful, as we can quickly summarize our various segments or groups of records. Here's what the syntax looks like. We have SELECT rating COUNT of film_id, which is going to count the number of film_id values, FROM our film table and GROUP BY rating. My pro tip for GROUP BY and aggregate functions is to really think of it just like pivot tables in the sense that you're creating segments and having different summarization metrics on top of those groups. Let's go into workbench and do some examples. AlL right, so here I've selected all of the data from our film table. Let's say we are interested in getting a summary of how many of our films have a specific rating. I'm going to go…

Contents