本帖最后由 jayan611 于 2011-04-16 15:28:06 编辑

解决方案 »

  1.   


    --这样试试看看
    insert into lm_kqMonthTotal
    select kqMonthTotal_SEQ.NEXTVAL,
    pid,
    m.type,
    nvl((sum(m.dtime) over(partition by m.type) * 60, 0)
    from (select k.id,
                 t.id as type,
                 cast((to_date(BeginDate, 'yyyy/mm/dd hh24:mi:ss') -
                       to_date(EndDate, 'yyyy/mm/dd hh24:mi:ss')) * 24 as
                         float) as dtime
            from lm_kqBatchApplyLeaveBak k
            right join lm_kqApplyLeaveType t on k.ApplyLeaveTypeID = t.id
            and k.pid = pid
            and BeginDate between
                 begintime and endtime) m
    where m.type > 11