Codecademy Forums

FAQ: Code Challenge: Aggregate Functions - Code Challenge 9

This community-built FAQ covers the “Code Challenge 9” exercise from the lesson “Code Challenge: Aggregate Functions”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development
Data Science

FAQs on the exercise Code Challenge 9

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

SELECT MAX(watch_duration_in_minutes) AS ‘MAX Duration’, MIN (watch_duration_in_minutes) AS ‘MIN Duration’
FROM watch_history;

The above code is correct but just curious why this is wrong:

SELECT watch_duration_in_minutes AS ‘Duration’, MAX(Duration), MIN(Duration)
FROM watch_history;

What if I wanted to know the user_id and watch_date of both the longest and shortest event? Can this be done in one query?

My instructions say to rename the results. When trying to add the AS statement it would not accept my answer. When I clicked the hint it did not have the AS statements. So why is it telling me to rename anything? Did anyone else have this issue or did I just massively over think this test?

I thought the same thing. I had renamed them and it was failing me. Then I noticed that the order of the MIN, MAX makes a difference. If you use MIN first it fails but MAX first succeeds, named or not.

Use AS. Once a column has been renamed with AS, the new name will work in the later steps in your query.

SELECT long_name AS short_name 
FROM my_table
WHERE short_name > 30;