如题:
id              enterprise
01                   a
01                   b
02                   c
03                   a
03                   b
03                   c最终要能得到一个03,当然了,如果还有其他和03一样的也一起得到

解决方案 »

  1.   

    select *
    from tab tt
    group by tt.id
    having count(*) = (select count(*)
                       from tab t
                       group by t.id
                      )
      

  2.   

    with summary as (select id,count(*) r_num from test group by id)                  
    select id from summary 
    where r_num=(select max(r_num) from summary)
      

  3.   

    帅哥,这样好像不太行啊
    select *
    from tab tt
    group by tt.id
    having count(*) = (select Max(count(*))      --这里改一下到是能得到结果
                       from tab t
                       group by t.id
                      )嗯谢谢了
      

  4.   

    demo@XIAOXIAO>select * from teste;ID   ENTE
    ---- ----
    01   a
    01   b
    02   c
    03   a
    03   b
    03   c
    04   a
    04   b
    04   d已选择9行。demo@XIAOXIAO>select id from
      2  (select id, dense_rank()over(order by cid desc ) as rid
      3    from (select id, count(1) as cid from teste group by id)
      4    )
      5  where rid = 1  ;ID
    ----
    03
    04