FAQ: Aggregate Functions - Count

This community-built FAQ covers the “Count” exercise from the lesson “Aggregate Functions”.

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

Web Development
Data Science

Learn SQL

FAQs on the exercise Count

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!

I have a question regarding SELECT COUNT(*) FROM table_name:
It was said that this returns all the rows that have a non-empty value in the specified column. Here, we use * for all columns.

  1. It is absolutely certain that this statement will return all the rows in the table because at least one of the columns of a row will have a non-empty value?

  2. If the value in a column is NULL, will it be counted as a non-empty or as an empty column?



See this: What's the difference between COUNT(1), COUNT(*), and COUNT(column_name)?

The way CodeCademy introduces the COUNT() function is just misleading. After defining it as “counts the number of non-empty values in that column”, the first example they give is COUNT(*), no column specified, which is a special case where the COUNT function does count empty values as well…

** FROM fake_apps

** WHERE price=0;**

The result returned from the above code is 73.

Does this mean that there are 73 non-empty values that is also 0 and under the price column?

  1. Is it correct to use the following sentence? “Let’s assume I want to use the COUNT aggregate…”

  2. How can I use the COUNT aggregate for few columns together? My attempt didn’t work out :slight_smile:

SELECT COUNT(id, name)
FROM fake_apps;

Anyone? :slight_smile:

I do not think you can do that.