From the course: SQL Essential Training
Unlock the full course today
Join today to access over 23,100 courses taught by industry experts.
Filtering with a grouped condition - SQL Tutorial
From the course: SQL Essential Training
Filtering with a grouped condition
- [Instructor] Now that we've taken a look at some of the most commonly used aggregate functions, now is a great time to mention that a useful feature of aggregate functions is their ability to calculate subtotals or aggregates for different groups of data. Now, looking at the invoice table of our WSDA Music database, we know that we can get the average amount for an invoice very easily with the use of a AVG function. Now, let's say that we had a new request from the WSDA Music Company management and they have asked us to calculate the average invoice amount by BillingCity. Now, let's take a look at how we would respond to such a request with SQL. As we usually do, let's start with the FROM clause. And we are interested in invoice amounts so let's go to the Invoice table. Now, above the FROM, I'm going to include our SELECT. And now, let's include the fields that we want to display. So that would be, if we take a look…
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.