How to run SQL query group by issue?

前端 未结 2 596
野趣味
野趣味 2021-01-24 03:05

I have a table with columns :

Table Name: IdentityTable

ID         Dest_Name       Dest_Reference_Id         Format        IG

31231231    India                  


        
相关标签:
2条回答
  • 2021-01-24 03:45

    Make two sub-queries and join em up.

    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
    
    0 讨论(0)
  • 2021-01-24 03:45
    count(*) over(partition by dest_name, dest_reference_id)
    

    and without a group by. google "oracle analytic functions".

    0 讨论(0)
提交回复
热议问题