By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
INSERT 0 3
| id | fruit | flavors | id | flavor |
|---|---|---|---|---|
| null | apple | {sweet,sour,delicious} | 1 | sweet |
| null | apple | {sweet,sour,delicious} | 1 | sour |
| null | apple | {sweet,sour,delicious} | 1 | delicious |
| null | apple | {sweet,tasty} | 2 | sweet |
| null | apple | {sweet,tasty} | 2 | tasty |
| null | banana | {sweet,delicious} | 3 | sweet |
| null | banana | {sweet,delicious} | 3 | delicious |
SELECT 7
| fruit | array_agg | count |
|---|---|---|
| apple | {delicious,sour,sweet,tasty} | 0 |
| banana | {delicious,sweet} | 0 |
SELECT 2