The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

I am confused using Count(*)

I am confused using Count(*)

Super Learner

I understand that * is a wildcard and what that is.
When using it in the SELECT statements, I understand that it considers all fields, so I dont need to specify them individually.
However, I am confused when I use it in the COUNT() statement. It seems that it should be returning all values in the table, not just the records.
What is the gap in my understanding with the solution to the exercises on the related lesson?
Thanks for any insight.


SELECT COUNT(*) FROM salaries WHERE salary > 100000;

1 Answer

365 Team

Hi Mike!
Thanks for reaching out.
In theory, there’s not much of a gap. COUNT(*) returns the number of all rows of the given field from the data set, including NULL values. If you are using a specific field as an argument (i.e. e.g. COUNT(emp_no)), the NULL values will be ignored and only the number of the non-null values will be retrieved.  
Hope this helps.

I think so. If I understand your explanation, the wildcard in the Count() function does not represent fields, but records including null values. Is that right?

4 months

Hi Mike! Please accept my apologies for the delayed response; somehow I had marked your question as answered. Yes, that’s right. You can also say that the wildcard represents ‘all fields’. Hope this helps. Best, Martin

4 months
Ready to Learn
Data Science?
50% OFF