By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| version |
|---|
| PostgreSQL 13.13 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-20), 64-bit |
SELECT 1
CREATE TABLE
INSERT 0 18
| ctry_id | label | item_name |
|---|---|---|
| 1 | Spain | Item#2 001 |
| 2 | Spain | Item#2 003 |
| 3 | France | Item#1 005 |
| 4 | null | Item#3 002 |
| 5 | France | Item#1 007 |
| 6 | Spain | Item#2 002 |
| 7 | France | Item#1 003 |
| 8 | France | Item#1 009 |
| 9 | France | Item#1 001 |
| 10 | null | Item#3 004 |
| 11 | null | Item#3 005 |
| 12 | null | Item#3 001 |
| 13 | France | Item#1 002 |
| 14 | null | Item#3 003 |
| 15 | France | Item#1 004 |
| 16 | Spain | Item#2 004 |
| 17 | France | Item#1 008 |
| 18 | France | Item#1 006 |
SELECT 18
| <null> | France | Spain |
|---|---|---|
| 5 | 9 | 4 |
SELECT 1
INSERT 0 7
INSERT 0 18
| <null> | France | Spain | Portugal |
|---|---|---|---|
| 10 | 18 | 8 | 7 |
SELECT 1
| label | count |
|---|---|
| null | 10 |
| France | 18 |
| Portugal | 7 |
| Spain | 8 |
SELECT 4
INSERT 0 3
| label | count |
|---|---|
| null | 10 |
| France | 18 |
| Germany | 3 |
| Portugal | 7 |
| Spain | 8 |
SELECT 5