By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE "order" (id int primary key, customer_id int null);
✓
INSERT INTO "order" (id, customer_id) VALUES (1, NULL);
✓
SELECT id, COUNT(DISTINCT customer_id) FROM "order" GROUP BY "order"."id"
id | COUNT(DISTINCT customer_id) |
---|---|
1 | 0 |