By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE
CREATE INDEX
INSERT 0 1
ERROR: duplicate key value violates unique constraint "idx" DETAIL: Key (( CASE WHEN type = 11 THEN type ELSE NULL::integer END))=(11) already exists.
INSERT 0 2
| id | account | author | type |
|---|---|---|---|
| 1 | 1 | Иванов | 11 |
| 3 | 1 | Иванов | 12 |
| 4 | 1 | Сидоров | 12 |
SELECT 3