SELECT
    COUNT(value),
    LOWER(COALESCE(SUBSTRING(value from '.*@(.*)>'), value)) AS id
FROM
    header
WHERE
    name = 'Message-Id'
GROUP BY
    id
ORDER BY
    count DESC
;
