Wykonaj dwa podzapytania i dołącz do nich.
SELECT counts.dest_name,
counts.dest_reference_id,
counts.total_format,
idents.format,
idents.IG
FROM
(
select dest_name, dest_reference_id, count (format) as total_format
from IdentityTable
Group By dest_name, dest_reference_id;
) counts
join
(
select distinct dest_name, dest_reference_id, format, IG
from identitytable
) idents
on counts.dest_name = idents.dest_name
and counts.dest_reference_id = idents.dest_reference_id