FAQ: Code Challenge: Aggregate Functions - Code Challenge 1

This community-built FAQ covers the “Code Challenge 1” 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 1

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!

Why is it when I get stuck and ask for the solution, it gives me what is already on the screen? After I do the task and RUN it, an error comes up at the bottom. I ask for the SOLUTION, and it gives me the same answer I put up but then a green check is there. Did I do it wrong or right?

Before picking the solution, copy all your code and paste it into your text editor, then when the solution appears, copy and paste it, as well; then compare the two.

The difference can be subtle and in some cases almost trivial. The SCT has a limited range of checking options and is not exhaustive.

From my experience the learning environment interface is sometimes buggy and there is no sure fire way to get around it. I end up doing lots of refreshes, Reset, etc. Just be sure to have a copy on hand of your latest work so you have some place to restart from.

1 Like

Thanks for the help, mtf. But seriously, right now, I am feeling a little overwhelmed. I may be one of those people who can’t learn on their own. I may need a classroom. I mean, it seems to be going so slow and I feel as if I’m not learning anything. Any suggestions?

Hello, Lynne. I hope you kept going. Learning to code is a challenge, and like learning anything else, we have to stick to it. (Sometimes a break – for a minute, a day, a week, or longer – is helpful. While you take a break on one language, give another a shot.)

This code the Aggregate Functions challenge doesn’t make sense to me:

SELECT COUNT(*) AS COUNT

FROM users

WHERE email LIKE ‘%.com’;

I have no clue as to why we use the ‘AS’ clause in this as well as keep getting confused as to the ‘%’ spacing on every question because sometimes it’s ‘whatever%’ or '%whatever%'or ‘%whatever’ and they all mean different things

Then the follow up question, why is AS used as it is in this problem?

SELECT first_name, COUNT(*) AS ‘count’
FROM users
GROUP BY first_name
ORDER BY 2 DESC;

1 Like

When you run the script, you see that the column name in the Query Results is presented as count rather than COUNT(*). As the programmer, you understand the difference. If you are coding this for someone else’s use, that person (customer, perhaps) won’t necessarily know what COUNT(*) means.

Here’s an analogy from the everyday world: acetylsalicylic acid is commonly known as aspirin. Which of those is meaningful to the non-expert?

1 Like

So its more for courtesy of others than it is actually required to pass the exercise? lol They mentioned nothing about adding an AS clause so i never though of it. Here I was doubting my ability lol

It never occurred to me to use the AS clause until I compared my query results to the provided hint :flushed: Makes sense - I know I wouldn’t want to provide a data set to someone else with COUNT(*) as one of the column headers. Wish I’d remember to apply a basic SQL concept :roll_eyes: :smile: