Intern
What does the COUNT function do?
sobes.tech AI
Answer from AI
Aggregates data by counting the number of rows in a dataset. Ignores NULL values in the specified column if provided.
COUNT(*): Counts all rows, including those with NULL in any column.COUNT(column): Counts rows where the specified column is not NULL.COUNT(DISTINCT column): Counts the number of unique, non-NULL values in the specified column.
Example usage in SQL:
SELECT COUNT(*) FROM users; -- Count all users
SELECT COUNT(email) FROM users; -- Count users with a specified email
SELECT COUNT(DISTINCT city) FROM users; -- Count unique user cities