>_ QueryLocal All recipes
SQL recipe

How do I count unique values in a column with SQL?

SELECT COUNT(DISTINCT customer) AS unique_customers FROM data;
Run this query in QueryLocal →

`COUNT(DISTINCT column)` counts how many different values appear in a column, ignoring duplicates — different from plain `COUNT(*)`, which would count every row even if the same customer placed five orders. This answers 'how many distinct customers/products/countries do I actually have', not 'how many rows mention one'.

A table named data with columns: order_id (integer), customer (text), country (text), category (text), quantity (integer), unit_price (real), order_date (text, YYYY-MM-DD).