PostgreSQL

PostgreSQL COUNT

Count rows or non-null values in PostgreSQL.

Count rows

SELECT COUNT(*) AS product_count
FROM products;

COUNT(*) counts rows, while COUNT(column_name) counts only non-null values in that column.

SELECT year, COUNT(*) AS products_in_year
FROM products
GROUP BY year;