Oracle
 sql >> Database >  >> RDS >> Oracle

Come eseguire il gruppo di query SQL per problema?

Crea due sottoquery e unisciti a loro.

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