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;
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?
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