Спойлер
Код: Выделить всё
CREATE TABLE customers
( customer_id INTEGER not null,
customer_name TEXT not null,
city TEXT,
);
INSERT INTO customers (customer_id, customer_name, city)
VALUES (7001, 'Microsoft', 'New York');
INSERT INTO customers (customer_id, customer_name, city)
VALUES (7007, 'NVIDIA', 'LA');
INSERT INTO customers (customer_id, customer_name, city)
VALUES (7008, 'NVIDIA', 'LA');
Код: Выделить всё
SELECT customer_name, COUNT(DISTINCT city) as "Distinct Cities"
FROM customers
GROUP BY customer_name;
Код: Выделить всё
SELECT COUNT(city FROM (SELECT DISTINCT city FROM customers);
Мне нужно видимо, что-то типа такого:
Код: Выделить всё
SELECT city, COUNT(DISTINCT city) as "Distinct Cities"
FROM customers
GROUP BY city;