select telno from tablename group by telno having count(*)=1

解决方案 »

  1.   

    select distinct(telno) from table_name where flag>=2;
    distinct 函数可忽略重复值。如想限制4月到6月可在条件后加上‘to_date(feemonth,'yyyymm') between to_date('200304','yyyymm') and to_date('200307','yyyymm')’
      

  2.   

    select distinct t1.telno
    from cw_tb t1,cw_tb t2
    where t1.telno = t2.telno and t1.feemonth = to_char(add_months(to_date(t2.feemonth||'01','YYYY-MM-DD'),1),'YYYYMM') and t1.flag > 1 and t2.flag > 1;解决问题:查出两个月以上连续flag>1!
      

  3.   

    select distinct telno from tablename where telno not in (select distinct telno from tablename where flag=1);
      

  4.   

    SELECT DISTINCT T1.TELNO 
    FROM TABLENAME T1,TABLENAME T2
    WHERE T1.TELNO=T2.TELNO 
    AND T1.FLAG>=2 
    AND T2.FLAG>=2 
    AND TO_NUMBER(TO_DATE(T1.FEEMONTH,'YYYY-MM-DD')-T0_DATE(T2.FEEMONTH,'YYYY-MM-DD')=1 
      

  5.   

    select telno from 
    (select telno,flag-lead(flag,1,0) over(order by feemonth desc) num,flag from tabname order by feemonth desc)
    where num=1 and flag=2