select distinct caller, callee, dnis_eq, key_trace, start_date, start_time
 from ivrlog
 where start_date='20100704' and callee!='1006' order by start_date desc, start_time desc
请教各位大虾,如何如上,找出caller的非重复值,而且是同一个caller中的最小start_time的那个数据。背景:表中有17W条记录,其中caller有重复,重复的caller记录条中,是各时间段的记录。thx~

解决方案 »

  1.   

    select caller, callee, dnis_eq, key_trace, start_date, start_time
    from ivrlog a
    where not exists(select 1 from ivrlog b where a.caller = b.caller and a.start_time > b.start_time)
      

  2.   

    select caller, callee, dnis_eq, key_trace, start_date, start_time
    from ivrlog a
    where start_time=(select min(start_time) from ivrlog b where a.caller = b.caller)
      

  3.   

    参考:http://blog.csdn.net/htl258/archive/2009/04/16/4083040.aspx
      

  4.   

    那这个限定条件该放在哪呢?
    a.start_time='20100704' and a.callee!='1006' and a.callee!='1106' and
      

  5.   

    有点乱,仔细研究一下SQL的语句就可以了
      

  6.   

    /* 2 */
    select caller, callee, dnis_eq, key_trace, ext5_skill, ext9_skill, se_id, start_date, start_time, end_date, end_time
    from ivrlog a
    where start_date='20100705' and callee!='1006' and callee!='1106' and start_time=(select min(start_time) from ivrlog b where start_date='20100705' and callee!='1006' and callee!='1106' and a.caller = b.caller) order by start_date asc, start_time asc
    忘记贴出来了。
      

  7.   

    SQL用得少,很难做出来,还得感谢各位大拿提点呀~