我得msn:[email protected]

解决方案 »

  1.   

    语句可以简化
    select count(distinct(ip)) countip,com_id from ipwarn
    group by com_id 
    having countip>1你说的超过8个之后,要干什么?
    而且你的语句中也没有体现出来8啊
      

  2.   

    现在这个sql没有什么问题。我想根据这个sql查出来的com_id去更新另一个表所对应的com_id的记录。用存储过程,怎么实现呢
      

  3.   

    用户ip统计表:ipwarn
            com_id    ip                  time
    285 127.0.0.1 2004-8-18 10:55:41
    285 127.0.0.1 2004-8-18 11:01:01
    285 10.200.7.160 2004-8-18 11:05:47
    285 10.200.7.160 2004-8-18 11:06:03
    285 127.0.0.1 2004-8-18 14:40:31
    285 127.0.0.1 2004-8-18 14:43:14
    336 127.0.0.1 2004-8-18 15:01:13
    337 127.0.0.1 2004-8-18 15:03:45
    335 127.0.0.1 2004-8-18 15:12:03
    每天晚上12点统计ipwarn,如果同一个com_id有8个不同的ip地址,就修改com_info表中的status=0。自动执行。
      

  4.   

    update com_info a set a.status=0 where a.com_id in ( select com_id,count(ip) from (select distinct com_id,ip from ipwarn group by com_id) group by com_id having count(ip)>=8)--这是更新语句,自动执行的话要建一JOB的.
      

  5.   

    一楼的大虾   是不是应该写成distinct ip,com_id  我不太清楚顺便问问
      

  6.   

    update com_info a
       set a.status = 0
     where 8 <= (select count (distinct ip)
                   from ipwarn
                  where com_id = a.com_id);
      

  7.   

    呵呵,丁满Oracle学习中……
    好东西!又学了一招!