>_ QueryLocal All recipes
SQL recipe

How do I count distinct category values with SQL?

SELECT COUNT(DISTINCT category) AS unique_category FROM data;
Run this query in QueryLocal →

`COUNT(DISTINCT category)` counts how many different category values appear across the table, ignoring how many rows repeat each one — different from `COUNT(*)`, which would count every row regardless of repetition.

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).