Count Distinct Customers
EasySQLDatabaseMathSorting
Description
Write a SQL query to return the number of distinct customers in the orders table as a single value named cnt. **Output columns (in order):** cnt
Table:
orders| Column | Type |
|---|---|
| id | INT |
| customer | TEXT |
Examples
Input:
CREATE TABLE orders (id INT, customer TEXT); INSERT INTO orders VALUES (1,'A'),(2,'B'),(3,'A');Output:
2Explanation:
Counting the unique customer values gives how many different customers placed orders.
Input:
CREATE TABLE orders (id INT, customer TEXT); INSERT INTO orders VALUES (1,'X');Output:
1Explanation:
Counting the unique customer values gives how many different customers placed orders.
Input:
CREATE TABLE orders (id INT, customer TEXT); INSERT INTO orders VALUES (1,'A'),(2,'A'),(3,'A');Output:
1Explanation:
Counting the unique customer values gives how many different customers placed orders.
Constraints
- •
Use standard SQL (SQLite).