Question about Code Challenge: Aggregate Functions using AS operator

link https://www.codecademy.com/programs/6ab2eb565d606af4d5dc4976a2338db8/content-items/0a25ec9bcbdfe5ce9179f1f315a29916/exercises/count1

The instructions in 2/10 are to:

Use COUNT() and a LIKE operator to determine the number of users that have an email ending in ‘.com’.

My incorrect solution was:

SELECT COUNT(*)
FROM users
WHERE email LIKE ‘%.com’;

After trying to figure it out, I check the solution provided which is:

SELECT COUNT(*) AS count
FROM users
WHERE email LIKE ‘%.com’;

I am still unclear why this query requires the use of AS. My understand so far is that the AS is used to rename a column, so is there a reason that is required in this case that I am missing?

1 Like

The column name normally takes the string you use for requesting data.

In this case the column name should be something like COUNT or COUNT(*) without the use of as.
Al tho it still gets the right information it is not very nice to look at.

This probably broke because Codecadamy asked to name the column. If not you should add a bug report from the lesson (found if you scroll down where the instructions are listed).