本帖最后由 yctcsms 于 2011-09-27 14:09:19 编辑

解决方案 »

  1.   

    with a as (select distinct orderid,ENDTIME, BEGINTIME from TBLA)
    select sum(ENDTIME-BEGINTIME) AS all_days
    from a;
      

  2.   

    select  sum(endtime-begintime) from (select distinct orderid,endtime,begintime from tbla)
      

  3.   

    select max(ENDTIME)-min(BEGINTIME) AS all_days
    from a
    group by ORDERID
      

  4.   

    select count(*) from (select ENDTIME ,BEGINTIME from TBLA group by ENDTIME ,BEGINTIME )