Original query:

SELECT
    "epics".*
FROM
    "epics"
    INNER JOIN "label_links" ON "label_links"."target_id" = "epics"."id"
        AND "label_links"."target_type" = 1
    INNER JOIN "labels" ON "labels"."id" = "label_links"."label_id"
WHERE
    "epics"."group_id" = 2
    AND "labels"."title" IN (3, 4)
GROUP BY
    "epics"."id"
HAVING (COUNT(DISTINCT labels.title) = 2)
ORDER BY
    "epics"."id" DESC
LIMIT 20
OFFSET 0