select regname, t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime
 from monit_net_detail t left join monit_dev_hotarea k on t.groupid=k.groupid group by regname查询表是2个表的组合,现在想输出个count(regname),select regname, count(regname),t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime
 from monit_net_detail t left join monit_dev_hotarea k on t.groupid=k.groupid group by regname报错啊。
说不是分组。

解决方案 »

  1.   

     select count(regname),regname, t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime
     from monit_net_detail t left join monit_dev_hotarea k on t.groupid=k.groupid group by regname, t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime 是能执行了,但是不知对不对
      

  2.   

    select regname, count(regname),t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime
    from monit_net_detail t left join monit_dev_hotarea k on t.groupid=k.groupid 
    group by regname),t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime
    试试这样行不行
      

  3.   

    楼上的这样写肯定不对,lz不妨这样试试:
    select regname, count(regname),t.netbyte_in, t.netbyte_out, t.netbyte_out ,t.totaltime from monit_net_detail where regname in(select regname from monit_net_detail t left join monit_dev_hotarea k
    on t.groupid=k.groupid group by regname)
      

  4.   

    除了聚合函数等,在select条件中出现的字段必定要在group中出现!
      

  5.   

    怎么写都不对啊.....你是以regname分组,但是取的是groupid...明显有问题啊...如果有2个groupid 对应1个 regname,那oracle怎么知道你取哪个groupid