From the course: Learning SQL Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Calculate participant metrics

Solution: Calculate participant metrics - SQL Tutorial

From the course: Learning SQL Programming

Start my 1-month free trial

Solution: Calculate participant metrics

(upbeat music) - [Instructor] Here's my solution. It's important to note that while we're grouping by the state_code, in order to give these aggregate functions each only the data for individual states, we're ordering the list by average points. I'm using aliases here for max points and average points to clean up the result, giving me a little bit more of a human friendly header, but also so that I can use the alias here in the ORDER BY clause. That's not necessary in this case. I could just reuse the average function from up here, but it helps to keep things a little cleaner and guarantees that I'm not making a typo if I retype the function. That's even more important the longer and more complex a condition gets. So defining it once and giving it a name means I don't have to worry about it when I need to use the same thing again later. If your response looks something like this, great. If not, take another look and…

Contents