COUNT Function

tags: #sql/aggregate_functions

The COUNT() function returns the number of rows that matches a specified criterion.

SELECT COUNT(column_name) AS result
FROM table_name  
WHERE condition;

You can use (*) to select all rows from a particular column. Will count all rows in a column.

SELECT COUNT(*) AS result
FROM table_name;

To count the number of distinct values:

SELECT COUNT (DISTINCT column_name) AS result
FROM table_name;
Powered by Forestry.md