COUNT
The COUNT() function returns the count of rows of data that satisfy the conditions
specified in the query. They can be
used to count the full contents of the table or specific rows that satisfy conditions in the query. Let's look
at some examples.
Lets begin by selecting all data for product_name, supplier_id and cost
SELECT
product_name,
supplier_id,
cost
FROM products
Let's count the number of distinct product_names in the products table. The query will look like this:
SELECT COUNT(distinct product_name)
FROM products;
Let's query the products table to count allsupplier_id whose cost is over 100.
select count(distinct supplier_id) as suppliers
from products
where cost > 100