Need help in optimising the performance of a query

Need help in optimising the performance of a query. Below is the query that is executed on TABLE_A, TABLE_B and TABLE_C with record counts as 10M, 10m and 42 (only) respectively and it takes around 5-7 minutes to get 40 records:
SELECT DISTINCT a.T_ID_, a.FIRSTNAME, b.T_CODE, b.PRODUCT,
CASE WHEN TRUNC(b.DATE) +90 = TRUNC(SYSDATE) THEN -90 WHEN TRUNC(b.DATE) +30 = TRUNC(SYSDATE) THEN -30 ELSE 0 END AS T_DATE FROM TABLE_B b
INNER JOIN TABLE_A a ON (a.T_ID_ = b.T_ID_) LEFT JOIN TABLE_C c ON b.PRODUCT = c.PRODUCT
WHERE b.STATUS = 'T' AND (b.TYPE = 'ACTION'
AND ( TRUNC(b.DATE) + 1 = TRUNC(SYSDATE) ) ) AND b.PRODUCT = 2;
Note: Indices on the join columns are available in the respective tables
Please let me know if there is any better way to write it.
Edited by: 862944 on Aug 18, 2011 9:52 AM

862944 wrote:
Need help in optimising the performance of a query. Below is the query that is executed on TABLE_A, TABLE_B and TABLE_C with record counts as 10M, 10m and 42 (only) respectively and it takes around 5-7 minutes to get 40 records:
SELECT DISTINCT a.T_ID_, a.FIRSTNAME, b.T_CODE, b.PRODUCT,
CASE WHEN TRUNC(b.DATE) +90 = TRUNC(SYSDATE) THEN -90 WHEN TRUNC(b.DATE) +30 = TRUNC(SYSDATE) THEN -30 ELSE 0 END AS T_DATE FROM TABLE_B b
INNER JOIN TABLE_A a ON (a.T_ID_ = b.T_ID_) LEFT JOIN TABLE_C c ON b.PRODUCT = c.PRODUCT
WHERE b.STATUS = 'T' AND (b.TYPE = 'ACTION'
AND ( TRUNC(b.DATE) + 1 = TRUNC(SYSDATE) ) ) AND b.PRODUCT = 2;
Note: Indices on the join columns are available in the respective tables
Please let me know if there is any better way to write it.
Edited by: 862944 on Aug 18, 2011 9:52 AM[When Your Query Takes Too Long|https://forums.oracle.com/forums/thread.jspa?messageID=1812597]

Similar Messages

  • Need help in improving the performance for the sql query

    Thanks in advance for helping me.
    I was trying to improve the performance of the below query. I tried the following methods used merge instead of update, used bulk collect / Forall update, used ordered hint, created a temp table and upadated the target table using the same. The methods which I used did not improve any performance. The data count which is updated in the target table is 2 million records and the target table has 15 million records.
    Any suggestions or solutions for improving performance are appreciated
    SQL query:
    update targettable tt
    set mnop = 'G',
    where ( x,y,z ) in
    select a.x, a.y,a.z
    from table1 a
    where (a.x, a.y,a.z) not in (
    select b.x,b.y,b.z
    from table2 b
    where 'O' = b.defg
    and mnop = 'P'
    and hijkl = 'UVW';

    987981 wrote:
    I was trying to improve the performance of the below query. I tried the following methods used merge instead of update, used bulk collect / Forall update, used ordered hint, created a temp table and upadated the target table using the same. The methods which I used did not improve any performance. And that meant what? Surely if you spend all that time and effort to try various approaches, it should mean something? Failures are as important teachers as successes. You need to learn from failures too. :-)
    The data count which is updated in the target table is 2 million records and the target table has 15 million records.Tables have rows btw, not records. Database people tend to get upset when rows are called records, as records exist in files and a database is not a mere collection of records and files.
    The failure to find a single faster method with the approaches you tried, points to that you do not know what the actual performance problem is. And without knowing the problem, you still went ahead, guns blazing.
    The very first step in dealing with any software engineering problem, is to identify the problem. Seeing the symptoms (slow performance) is still a long way from problem identification.
    Part of identifying the performance problem, is understanding the workload. Just what does the code task the database to do?
    From your comments, it needs to find 2 million rows from 15 million rows. Change these rows. And then write 2 million rows back to disk.
    That is not a small workload. Simple example. Let's say that the 2 million row find is 1ms/row and the 2 million row write is also 1ms/row. This means a 66 minute workload. Due to the number of rows, an increase in time/row either way, will potentially have 2 million fold impact.
    So where is the performance problem? Time spend finding the 2 million rows (where other tables need to be read, indexes used, etc)? Time spend writing the 2 million rows (where triggers and indexes need to be fired and maintained)? Both?

  • Need help in analyzing the performance aspects of compounding

    Hi all,
    i am analyzing the performance aspects of compounding.
    can anyone guide me about how do i go about?

    when i displayed this table, it is showing some timestamps and validity period for the queries.  i am having some difficulty in understanding this table details.
    can u please guide me regarding this ?
    also can anyone please help me on how do i analyze the OLAP processor performance for the  queries that use compounding?

  • Needed help to improve the performance of a select query?

    Hi,
    I have been preparing a report which involves data to be fetched from 4 to 5 different tables and calculation has to performed on some columns also,
    i planned to write a single cursor to populate 1 temp table.i have used INLINE VIEW,EXISTS more frequently in the select query..please go through the query and suggest me a better way to restructure the query.
    cursor c_acc_pickup_incr(p_branch_code varchar2, p_applDate date, p_st_dt date, p_ed_dt date) is
    select sca.branch_code "BRANCH",
    sca.cust_ac_no "ACCOUNT",
    to_char(p_applDate, 'YYYYMM') "YEARMONTH",
    sca.ccy "CURRENCY",
    sca.account_class "PRODUCT",
    sca.cust_no "CUSTOMER",
    sca.ac_desc "DESCRIPTION",
    null "LOW_BAL",
    null "HIGH_BAL",
    null "AVG_CR_BAL",
    null "AVG_DR_BAL",
    null "CR_DAYS",
    null "DR_DAYS",
    --null                                 "CR_TURNOVER",       
    --null                                 "DR_TURNOVER",       
    null "DR_OD_DAYS",
    (select sum(gf.limit_amount * (scal.linkage_percentage / 100)) +
    (case when (p_applDate >= sca.tod_limit_start_date and
    p_applDate <= nvl(sca.tod_limit_end_date, p_applDate)) then
    sca.tod_limit else 0 end) dd
    from getm_facility gf, sttm_cust_account_linkages scal
    where gf.line_code || gf.line_serial = scal.linked_ref_no
    and cust_ac_no = sca.cust_ac_no) "OD_LIMIT",
    --sc.credit_rating                      "CR_GRADE",        
    null "AVG_NET_BAL",
    null "UNAUTH_OD_AMT",
    sca.acy_blocked_amount "AMT_BLOCKED",
    (select sum(amt)
    from ictb_entries_history ieh
    where ieh.acc = sca.cust_ac_no
    and ieh.brn = sca.branch_code
    and ieh.drcr = 'D'
    and ieh.liqn = 'Y'
    and ieh.entry_passed = 'Y'
    and ieh.ent_dt between p_st_dt and p_ed_dt
    and exists (
    select * from ictm_pr_int ipi, ictm_rule_frm irf
    where ipi.product_code = ieh.prod
    and ipi.rule = irf.rule_id
    and irf.book_flag = 'B')) "DR_INTEREST",
    (select sum(amt)
    from ictb_entries_history ieh
    where ieh.acc = sca.cust_ac_no
    and ieh.brn = sca.branch_code
    and ieh.drcr = 'C'
    and ieh.liqn = 'Y'
    and ieh.entry_passed = 'Y'
    and ieh.ent_dt between p_st_dt and p_ed_dt
    and exists (
    select * from ictm_pr_int ipi, ictm_rule_frm irf
    where ipi.product_code = ieh.prod
    and ipi.rule = irf.rule_id
    and irf.book_flag = 'B')) "CR_INTEREST",
    (select sum(amt) from ictb_entries_history ieh
    where ieh.brn = sca.branch_code
    and ieh.acc = sca.cust_ac_no
    and ieh.ent_dt between p_st_dt and p_ed_dt
    and exists (
    select product_code
    from ictm_product_definition ipd
    where ipd.product_code = ieh.prod
    and ipd.product_type = 'C')) "FEE_INCOME",
    sca.record_stat "ACC_STATUS",
    case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
    and not exists (select 1
    from ictm_tdpayin_details itd
    where itd.multimode_payopt = 'Y'
    and itd.brn = sca.branch_code
    and itd.acc = sca.cust_ac_no
    and itd.multimode_offset_brn is not null
    and itd.multimode_tdoffset_acc is not null))
    then 1 else 0 end "NEW_ACC_FOR_THE_MONTH",
    case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
    and trunc(sc.cif_creation_date,'MM') = trunc(p_applDate,'MM')
    and not exists (select 1
    from ictm_tdpayin_details itd
    where itd.multimode_payopt = 'Y'
    and itd.brn = sca.branch_code
    and itd.acc = sca.cust_ac_no
    and itd.multimode_offset_brn is not null
    and itd.multimode_tdoffset_acc is not null))
    then 1 else 0 end "NEW_ACC_FOR_NEW_CUST",
    (select 1 from dual
    where exists (select 1 from ictm_td_closure_renew itcr
    where itcr.brn = sca.branch_code
    and itcr.acc = sca.cust_ac_no
    and itcr.renewal_date = sysdate)
    or exists (select 1 from ictm_tdpayin_details itd
    where itd.multimode_payopt = 'Y'
    and itd.brn = sca.branch_code
    and itd.acc = sca.cust_ac_no
    and itd.multimode_offset_brn is not null
    and itd.multimode_tdoffset_acc is not null)) "RENEWED_OR_ROLLOVER",
    (select maturity_date from ictm_acc ia
    where ia.brn = sca.branch_code
    and ia.acc = sca.cust_ac_no) "MATURITY_DATE",
    sca.ac_stat_no_dr "DR_DISALLOWED",
    sca.ac_stat_no_cr "CR_DISALLOWED",
    sca.ac_stat_block                     "BLOCKED_ACC",       Not Reqd
    sca.ac_stat_dormant "DORMANT_ACC",
    sca.ac_stat_stop_pay "STOP_PAY_ACC", --New
    sca.ac_stat_frozen "FROZEN_ACC",
    sca.ac_open_date "ACC_OPENING_DT",
    sca.address1 "ADD_LINE_1",
    sca.address2 "ADD_LINE_2",
    sca.address3 "ADD_LINE_3",
    sca.address4 "ADD_LINE_4",
    sca.joint_ac_indicator "JOINT_ACC",
    sca.acy_avl_bal "CR_BAL",
    0 "DR_BAL",
    0 "CR_BAL_LCY", t
    0 "DR_BAL_LCY",
    null "YTD_CR_MOVEMENT",
    null "YTD_DR_MOVEMENT",
    null "YTD_CR_MOVEMENT_LCY",
    null "YTD_DR_MOVEMENT_LCY",
    null "MTD_CR_MOVEMENT",
    null "MTD_DR_MOVEMENT",
    null "MTD_CR_MOVEMENT_LCY",
    null "MTD_DR_MOVEMENT_LCY",
    'N' "BRANCH_TRFR", --New
    sca.provision_amount "PROVISION_AMT",
    sca.account_type "ACCOUNT_TYPE",
    nvl(sca.tod_limit, 0) "TOD_LIMIT",
    nvl(sca.sublimit, 0) "SUB_LIMIT",
    nvl(sca.tod_limit_start_date, global.min_date) "TOD_START_DATE",
    nvl(sca.tod_limit_end_date, global.max_date) "TOD_END_DATE"
    from sttm_cust_account sca, sttm_customer sc
    where sca.branch_code = p_branch_code
    and sca.cust_no = sc.customer_no
    and ( exists (select 1 from actb_daily_log adl
    where adl.ac_no = sca.cust_ac_no
    and adl.ac_branch = sca.branch_code
    and adl.trn_dt = p_applDate
    and adl.auth_stat = 'A')
    or exists (select 1 from catm_amount_blocks cab
    where cab.account = sca.cust_ac_no
    and cab.branch = sca.branch_code
    and cab.effective_date = p_applDate
    and cab.auth_stat = 'A')
    or exists (select 1 from ictm_td_closure_renew itcr
    where itcr.acc = sca.cust_ac_no
    and itcr.brn = sca.branch_code
    and itcr.renewal_date = p_applDate)
    or exists (select 1 from sttm_ac_stat_change sasc
    where sasc.cust_ac_no = sca.cust_ac_no
    and sasc.branch_code = sca.branch_code
    and sasc.status_change_date = p_applDate
    and sasc.auth_stat = 'A')
    or exists (select 1 from cstb_acc_brn_trfr_log cabtl
    where cabtl.branch_code = sca.branch_code
    and cabtl.cust_ac_no = sca.cust_ac_no
    and cabtl.process_status = 'S'
    and cabtl.process_date = p_applDate)
    or exists (select 1 from sttbs_provision_history sph
    where sph.branch_code = sca.branch_code
    and sph.cust_ac_no = sca.cust_ac_no
    and sph.esn_date = p_applDate)
    or exists (select 1 from sttms_cust_account_dormancy scad
    where scad.branch_code = sca.branch_code
    and scad.cust_ac_no = sca.cust_ac_no
    and scad.dormancy_start_dt = p_applDate)
    or sca.maker_dt_stamp = p_applDate
    or sca.status_since = p_applDate
    l_tb_acc_det ty_tb_acc_det_int;
    l_brnrec cvpks_utils.rec_brnlcy;
    l_acbr_lcy sttms_branch.branch_lcy%type;
    l_lcy_amount actbs_daily_log.lcy_amount%type;
    l_xrate number;
    l_dt_rec sttm_dates%rowtype;
    l_acc_rec sttm_cust_account%rowtype;
    l_acc_stat_row ty_r_acc_stat;
    Edited by: user13710379 on Jan 7, 2012 12:18 AM

    I see it more like shown below (possibly with no inline selects
    Try to get rid of the remaining inline selects ( left as an exercise ;) )
    and rewrite traditional joins as ansi joins as problems might arise using mixed syntax as I have to leave so I don't have time to complete the query
    select sca.branch_code "BRANCH",
           sca.cust_ac_no "ACCOUNT",
           to_char(p_applDate, 'YYYYMM') "YEARMONTH",
           sca.ccy "CURRENCY",
           sca.account_class "PRODUCT",
           sca.cust_no "CUSTOMER",
           sca.ac_desc "DESCRIPTION",
           null "LOW_BAL",
           null "HIGH_BAL",
           null "AVG_CR_BAL",
           null "AVG_DR_BAL",
           null "CR_DAYS",
           null "DR_DAYS",
    --     null "CR_TURNOVER",
    --     null "DR_TURNOVER",
           null "DR_OD_DAYS",
           w.dd "OD_LIMIT",
    --     sc.credit_rating "CR_GRADE",
           null "AVG_NET_BAL",
           null "UNAUTH_OD_AMT",
           sca.acy_blocked_amount "AMT_BLOCKED",
           x.dr_int "DR_INTEREST",
           x.cr_int "CR_INTEREST",
           y.fee_amt "FEE_INCOME",
           sca.record_stat "ACC_STATUS",
           case when trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
                 and not exists(select 1
                                  from ictm_tdpayin_details itd
                                 where itd.multimode_payopt = 'Y'
                                   and itd.brn = sca.branch_code
                                   and itd.acc = sca.cust_ac_no
                                   and itd.multimode_offset_brn is not null
                                   and itd.multimode_tdoffset_acc is not null
                then 1
                else 0
           end "NEW_ACC_FOR_THE_MONTH",
           case when (trunc(sca.ac_open_date,'MM') = trunc(p_applDate,'MM')
                 and trunc(sc.cif_creation_date,'MM') = trunc(p_applDate,'MM')
                 and not exists(select 1
                                  from ictm_tdpayin_details itd
                                 where itd.multimode_payopt = 'Y'
                                   and itd.brn = sca.branch_code
                                   and itd.acc = sca.cust_ac_no
                                   and itd.multimode_offset_brn is not null
                                   and itd.multimode_tdoffset_acc is not null
                then 1
                else 0
           end "NEW_ACC_FOR_NEW_CUST",
           (select 1 from dual
             where exists(select 1
                            from ictm_td_closure_renew itcr
                           where itcr.brn = sca.branch_code
                             and itcr.acc = sca.cust_ac_no
                             and itcr.renewal_date = sysdate
                or exists(select 1
                            from ictm_tdpayin_details itd
                           where itd.multimode_payopt = 'Y'
                             and itd.brn = sca.branch_code
                             and itd.acc = sca.cust_ac_no
                             and itd.multimode_offset_brn is not null
                             and itd.multimode_tdoffset_acc is not null
           ) "RENEWED_OR_ROLLOVER",
           m.maturity_date "MATURITY_DATE",
           sca.ac_stat_no_dr "DR_DISALLOWED",
           sca.ac_stat_no_cr "CR_DISALLOWED",
    --     sca.ac_stat_block "BLOCKED_ACC", --Not Reqd
           sca.ac_stat_dormant "DORMANT_ACC",
           sca.ac_stat_stop_pay "STOP_PAY_ACC", --New
           sca.ac_stat_frozen "FROZEN_ACC",
           sca.ac_open_date "ACC_OPENING_DT",
           sca.address1 "ADD_LINE_1",
           sca.address2 "ADD_LINE_2",
           sca.address3 "ADD_LINE_3",
           sca.address4 "ADD_LINE_4",
           sca.joint_ac_indicator "JOINT_ACC",
           sca.acy_avl_bal "CR_BAL",
           0 "DR_BAL",
           0 "CR_BAL_LCY", t
           0 "DR_BAL_LCY",
           null "YTD_CR_MOVEMENT",
           null "YTD_DR_MOVEMENT",
           null "YTD_CR_MOVEMENT_LCY",
           null "YTD_DR_MOVEMENT_LCY",
           null "MTD_CR_MOVEMENT",
           null "MTD_DR_MOVEMENT",
           null "MTD_CR_MOVEMENT_LCY",
           null "MTD_DR_MOVEMENT_LCY",
           'N' "BRANCH_TRFR", --New
           sca.provision_amount "PROVISION_AMT",
           sca.account_type "ACCOUNT_TYPE",
           nvl(sca.tod_limit, 0) "TOD_LIMIT",
           nvl(sca.sublimit, 0) "SUB_LIMIT",
           nvl(sca.tod_limit_start_date, global.min_date) "TOD_START_DATE",
           nvl(sca.tod_limit_end_date, global.max_date) "TOD_END_DATE"
      from sttm_cust_account sca,
           sttm_customer sc,
           (select sca.cust_ac_no
                   sum(gf.limit_amount * (scal.linkage_percentage / 100)) +
                       case when p_applDate >= sca.tod_limit_start_date
                             and p_applDate <= nvl(sca.tod_limit_end_date, p_applDate)
                            then sca.tod_limit else 0
                       end
                      ) dd
              from sttm_cust_account sca
                   getm_facility gf,
                   sttm_cust_account_linkages scal
             where gf.line_code || gf.line_serial = scal.linked_ref_no
               and cust_ac_no = sca.cust_ac_no
             group by sca.cust_ac_no
           ) w,
           (select acc,
                   brn,
                   sum(decode(drcr,'D',amt)) dr_int,
                   sum(decode(drcr,'C',amt)) cr_int
              from ictb_entries_history ieh
             where ent_dt between p_st_dt and p_ed_dt
               and drcr in ('C','D')
               and liqn = 'Y'
               and entry_passed = 'Y'
               and exists(select null
                            from ictm_pr_int ipi,
                                 ictm_rule_frm irf
                           where ipi.rule = irf.rule_id
                             and ipi.product_code = ieh.prod 
                             and irf.book_flag = 'B'
             group by acc,brn
           ) x,
           (select acc,
                   brn,
                   sum(amt) fee_amt
              from ictb_entries_history ieh
             where ieh.ent_dt between p_st_dt and p_ed_dt
               and exists(select product_code
                            from ictm_product_definition ipd
                           where ipd.product_code = ieh.prod
                             and ipd.product_type = 'C'
             group by acc,brn
           ) y,
           ictm_acc m,
           (select sca.cust_ac_no,
                   sca.branch_code
                   coalesce(nvl2(coalesce(t1.ac_no,t1.ac_branch),'exists',null),
                            nvl2(coalesce(t2.account,t2.account),'exists',null),
                            nvl2(coalesce(t3.acc,t3.brn),'exists',null),
                            nvl2(coalesce(t4.cust_ac_no,t4.branch_code),'exists',null),
                            nvl2(coalesce(t5.cust_ac_no,t5.branch_code),'exists',null),
                            nvl2(coalesce(t6.cust_ac_no,t6.branch_code),'exists',null),
                            nvl2(coalesce(t7.cust_ac_no,t7.branch_code),'exists',null),
                            decode(sca.maker_dt_stamp,p_applDate,'exists'),
                            decode(sca.status_since,p_applDate,'exists')
                           ) existence
              from sttm_cust_account sca
                   left outer join
                   (select ac_no,ac_branch
                      from actb_daily_log
                     where trn_dt = p_applDate
                       and auth_stat = 'A'
                   ) t1
                on (sca.cust_ac_no = t1.ac_no
               and  sca.branch_code = t1.ac_branch
                   left outer join
                   (select account,account
                      from catm_amount_blocks
                     where effective_date = p_applDate
                       and auth_stat = 'A'
                   ) t2
                on (sca.cust_ac_no = t2.account
               and  sca.branch_code = t2.branch
                   left outer join
                   (select acc,brn
                      from ictm_td_closure_renew itcr
                     where renewal_date = p_applDate
                   ) t3
                on (sca.cust_ac_no = t3.acc
               and  sca.branch_code = t3.brn
                   left outer join
                   (select cust_ac_no,branch_code
                      from sttm_ac_stat_change
                     where status_change_date = p_applDate
                       and auth_stat = 'A'
                   ) t4
                on (sca.cust_ac_no = t4.cust_ac_no
               and  sca.branch_code = t4.branch_code
                   left outer join
                   (select cust_ac_no,branch_code
                      from cstb_acc_brn_trfr_log
                     where process_date = p_applDate
                       and process_status = 'S'
                   ) t5
                on (sca.cust_ac_no = t5.cust_ac_no
               and  sca.branch_code = t5.branch_code
                   left outer join
                   (select cust_ac_no,branch_code
                      from sttbs_provision_history
                     where esn_date = p_applDate
                   ) t6
                on (sca.cust_ac_no = t6.cust_ac_no
               and  sca.branch_code = t6.branch_code
                   left outer join
                   (select cust_ac_no,branch_code
                      from sttms_cust_account_dormancy
                     where dormancy_start_dt = p_applDate
                   ) t7
                on (sca.cust_ac_no = t7.cust_ac_no
               and  sca.branch_code = t7.branch_code
           ) z
    where sca.branch_code = p_branch_code
       and sca.cust_no = sc.customer_no
       and sca.cust_ac_no = w.cust_ac_no
       and sca.cust_ac_no = x.acc
       and sca.branch_code = x.brn
       and sca.cust_ac_no = y.acc
       and sca.branch_code = y.brn
       and sca.cust_ac_no = m.acc
       and sca.branch_code = m.brn
       and sca.cust_ac_no = z.sca.cust_ac_no
       and sca.branch_code = z.branch_code
       and z.existence is not nullRegards
    Etbin

  • Need help in displaying the status in one query

    Query:
    SELECT START_DATE,END_DATE,ABSENCE_TYPE,APPROVAL_STATUS,SUM(ABSENCE_DAYS),absence_attendance_id FROM(
    SELECT *
    FROM (SELECT NVL (paa.date_start, paa.date_projected_start) start_date,
    NVL (paa.date_end, paa.date_projected_end) end_date,
    paattl.NAME absence_type,
    (SELECT meaning
    FROM hr_lookups
    WHERE 'A' = lookup_code(+)
    AND 'LEAVE_STATUS' = lookup_type(+)) approval_status,
    NVL(paa.absence_days,
    hr_absutil_ss.getabsdurdays
    (paat.absence_attendance_type_id,
    paa.business_group_id,
    paa.creation_date,
    paa.person_id,
    paa.date_projected_start,
    paa.date_projected_end,
    paa.time_projected_start,
    paa.time_projected_end
    ) absence_days,
    paa.absence_attendance_id
    FROM per_absence_attendances paa,
    per_absence_attendance_types paat,
    per_abs_attendance_types_tl paattl,
    hr_lookups fcl
    WHERE paa.person_id = 155253
    AND paa.business_group_id = 112
    AND paa.absence_attendance_type_id =
    paat.absence_attendance_type_id
    AND paat.absence_attendance_type_id =
    paattl.absence_attendance_type_id
    AND paattl.LANGUAGE = USERENV ('LANG')
    AND fcl.lookup_type(+) = 'ABSENCE_CATEGORY'
    AND paat.absence_category = fcl.lookup_code(+)
    AND ( ( hr_api.return_legislation_code
    (paat.business_group_id) =
    'GB'
    AND NVL (paat.absence_category, '#') NOT IN
    ('M', 'GB_PAT_ADO', 'GB_PAT_BIRTH', 'GB_ADO')
    OR ( hr_api.return_legislation_code
    (paat.business_group_id) <>
    'GB'
    AND NVL (paat.absence_category, '#') NOT IN
    ('GB_PAT_ADO', 'GB_PAT_BIRTH', 'GB_ADO')
    AND NOT EXISTS (
    SELECT 'e'
    FROM hr_api_transactions t
    WHERE t.selected_person_id = paa.person_id
    AND t.creator_person_id = NVL (155253, t.creator_person_id)
    AND t.transaction_ref_table = 'PER_ABSENCE_ATTENDANCES'
    AND t.transaction_ref_id = paa.absence_attendance_id
    AND NOT ( hr_absutil_ss.getabsencetype
    (t.transaction_id,
    NULL
    ) IS NULL
    AND t.status = 'W'
    AND t.status NOT IN ('D', 'E'))
    UNION ALL
    SELECT hr_absutil_ss.getstartdate (hat.transaction_id,
    NULL
    ) start_date,
    hr_absutil_ss.getenddate (hat.transaction_id, NULL) end_date,
    hr_absutil_ss.getabsencetype
    (hat.transaction_id,
    NULL
    ) absence_type,
    hr_absutil_ss.getapprovalstatus
    (hat.transaction_id,
    NULL
    ) approval_status,
    hr_absutil_ss.getabsencedaysduration
    (hat.transaction_id,
    NULL
    ) absence_days,
    hat.transaction_ref_id absence_attendance_id
    FROM hr_api_transactions hat, hr_api_transaction_steps hats
    WHERE hat.transaction_ref_table = 'PER_ABSENCE_ATTENDANCES'
    AND hat.transaction_group = 'ABSENCE_MGMT'
    AND hat.transaction_identifier = 'ABSENCES'
    AND hat.transaction_ref_id IS NOT NULL
    AND hat.selected_person_id = 155253
    AND hat.creator_person_id = NVL (155253, hat.creator_person_id)
    AND hat.transaction_id = hats.transaction_id(+)
    AND hat.status NOT IN ('D', 'E')
    AND NOT ( hr_absutil_ss.getabsencetype (hat.transaction_id,
    NULL
    ) IS NULL
    AND hat.status = 'W'
    -- WHERE start_date = to_date(c_start_time) and end_date = to_date(c_stop_time)
    where absence_type NOT IN ('Emergency Call Up Military','On/Off Ramp','Paternity Leave','Maternity Leave'
    ,'Medical Leave','Parental Leave','Personal Leave','Bereavement Leave'
    ,'Marriage Leave','Moving House Leave','Military Duty Leave','Paternity','Adoption Leave',
    'Bereavement') ORDER BY start_date DESC )
    WHERE approval_status IN ('Pending For Approval','Approved','Rejected')
    GROUP BY START_DATE,END_DATE,ABSENCE_TYPE,APPROVAL_STATUS,absence_attendance_id;
    Current Output:
    Start_date End_date absence_type approval_status sum(absence_days) absence_attendance_id
    8/12/2010 8/13/2010 Standard Vacation Approved 2 10006531
    6/10/2011 6/10/2011 Standard Vacation Pending For Approval 1 10833750
    Expected Output:
    Start_date End_date absence_type approval_status sum(absence_days) absence_attendance_id
    8/12/2010 8/13/2010 Standard Vacation Approved 2 10006531
    6/10/2011 6/10/2011 Standard Vacation Submitted 1 10833750
    I need to change the "Pending for Approval " status to "Submitted".I tried using DECODE but not working.Can anyone help?
    Other Status will not be changing.
    Thanks
    Hibin

    /* Formatted on 6/24/2011 7:30:30 AM (QP5 v5.149.1003.31008) */
      SELECT START_DATE,
             END_DATE,
             ABSENCE_TYPE,
             DECODE (APPROVAL_STATUS,
                      'Submitted',
                      'Pending for Approval',
                      APPROVAL_STATUS)
                APPROVAL_STATUS,
             SUM (ABSENCE_DAYS),
             absence_attendance_id
        FROM (  SELECT *
                  FROM (SELECT NVL (paa.date_start, paa.date_projected_start)
                                  start_date,
                               NVL (paa.date_end, paa.date_projected_end) end_date,
                               paattl.NAME absence_type,
                               (SELECT meaning
                                  FROM hr_lookups
                                 WHERE 'A' = lookup_code(+)
                                       AND 'LEAVE_STATUS' = lookup_type(+))
                                  approval_status,
                               NVL (paa.absence_days,
                                    hr_absutil_ss.
                                     getabsdurdays (paat.absence_attendance_type_id,
                                                    paa.business_group_id,
                                                    paa.creation_date,
                                                    paa.person_id,
                                                    paa.date_projected_start,
                                                    paa.date_projected_end,
                                                    paa.time_projected_start,
                                                    paa.time_projected_end))
                                  absence_days,
                               paa.absence_attendance_id
                          FROM per_absence_attendances paa,
                               per_absence_attendance_types paat,
                               per_abs_attendance_types_tl paattl,
                               hr_lookups fcl
                         WHERE paa.person_id = 155253 AND paa.business_group_id = 112
                               AND paa.absence_attendance_type_id =
                                      paat.absence_attendance_type_id
                               AND paat.absence_attendance_type_id =
                                      paattl.absence_attendance_type_id
                               AND paattl.LANGUAGE = USERENV ('LANG')
                               AND fcl.lookup_type(+) = 'ABSENCE_CATEGORY'
                               AND paat.absence_category = fcl.lookup_code(+)
                               AND ( (hr_api.
                                       return_legislation_code (
                                         paat.business_group_id) = 'GB'
                                      AND NVL (paat.absence_category, '#') NOT IN
                                             ('M',
                                              'GB_PAT_ADO',
                                              'GB_PAT_BIRTH',
                                              'GB_ADO'))
                                    OR (hr_api.
                                         return_legislation_code (
                                           paat.business_group_id) <> 'GB'
                                        AND NVL (paat.absence_category, '#') NOT IN
                                               ('GB_PAT_ADO',
                                                'GB_PAT_BIRTH',
                                                'GB_ADO')))
                               AND NOT EXISTS
                                          (SELECT 'e'
                                             FROM hr_api_transactions t
                                            WHERE t.selected_person_id =
                                                     paa.person_id
                                                  AND t.creator_person_id =
                                                         NVL (155253,
                                                              t.creator_person_id)
                                                  AND t.transaction_ref_table =
                                                         'PER_ABSENCE_ATTENDANCES'
                                                  AND t.transaction_ref_id =
                                                         paa.absence_attendance_id
                                                  AND NOT (hr_absutil_ss.
                                                            getabsencetype (
                                                              t.transaction_id,
                                                              NULL)
                                                              IS NULL
                                                           AND t.status = 'W')
                                                  AND t.status NOT IN ('D', 'E'))
                        UNION/**/ ALL
                        SELECT hr_absutil_ss.getstartdate (hat.transaction_id, NULL)
                                  start_date,
                               hr_absutil_ss.getenddate (hat.transaction_id, NULL)
                                  end_date,
                               hr_absutil_ss.
                                getabsencetype (hat.transaction_id, NULL)
                                  absence_type,
                               hr_absutil_ss.
                                getapprovalstatus (hat.transaction_id, NULL)
                                  approval_status,
                               hr_absutil_ss.
                                getabsencedaysduration (hat.transaction_id, NULL)
                                  absence_days,
                               hat.transaction_ref_id absence_attendance_id
                          FROM hr_api_transactions hat, hr_api_transaction_steps hats
                         WHERE hat.transaction_ref_table = 'PER_ABSENCE_ATTENDANCES'
                               AND hat.transaction_group = 'ABSENCE_MGMT'
                               AND hat.transaction_identifier = 'ABSENCES'
                               AND hat.transaction_ref_id IS NOT NULL
                               AND hat.selected_person_id = 155253
                               AND hat.creator_person_id =
                                      NVL (155253, hat.creator_person_id)
                               AND hat.transaction_id = hats.transaction_id(+)
                               AND hat.status NOT IN ('D', 'E')
                               AND NOT (hr_absutil_ss.
                                         getabsencetype (hat.transaction_id, NULL)
                                           IS NULL
                                        AND hat.status = 'W'))
                 -- WHERE start_date = to_date(c_start_time) and end_date = to_date(c_stop_time)
                 WHERE absence_type NOT IN
                          ('Emergency Call Up Military',
                           'On/Off Ramp',
                           'Paternity Leave',
                           'Maternity Leave',
                           'Medical Leave',
                           'Parental Leave',
                           'Personal Leave',
                           'Bereavement Leave',
                           'Marriage Leave',
                           'Moving House Leave',
                           'Military Duty Leave',
                           'Paternity',
                           'Adoption Leave',
                           'Bereavement')
              ORDER BY start_date DESC)
       WHERE approval_status IN ('Pending For Approval', 'Approved', 'Rejected')
    GROUP BY START_DATE,
             END_DATE,
             ABSENCE_TYPE,
             APPROVAL_STATUS,
             absence_attendance_id;

  • I need help understanding how the Apple components integrate to create a system across all my devices?

    I need help understanding how the Apple components connect to create a whole system across all my devices?
    Is there a resource that describes current system and associated functionality?
    For example:
    Buy A, B, C to achieve "X" 
    You will need:
    an internet provider which supports <specs>
    add D to achieve "Y"
    You will need:
    an internet provider which supports <specs>
    add "E" to achieve "Z"
    You will need:
    an internet provider which supports <specs>
    For example, I am looking at the Gen 6 Airport extreme.  For intended performance do I need broadband? if so what are the specs, or will basic internet service suffice?  Do I need the internet provider's modem or does the Airport extreme replace that?  And then I think, if I am doing this, I should also look at Apple TV....What do I need and Why?  Then I look at the New Desk top coming out in the fall, and I think well, if I wait and get this, what does this component do for the system, and what becomes redundant? What does this awesome desktop do for my ability to sit and use a new macbook air when I travel  or sit on the couch in my PJs?
    If there was a place that plainly stated "if you buy the new dektop you can configure a system including only these components and achieve <this result> and by adding <additional components> you will achieve this result.
    I have been to the genius store a few times, but I come out of there more confused unless I have SPECIFIC questions or already know what to buy. 
    A "System Configuration App" would be a really great sales tool--Just saying.

    I have no idea what "fully optimized" means.
    No Apple device will let you watch broadcast TV. The Apple TV is a good option for watching streaming TV from iTunes, NetFlix and Hulu. If you want to watch from other sources, you may need to look at other devices.
    Any Mac computer or iPad will allow you to surf the web.
    What business software?
    Time Capsule is a good option for back ups.
    Update what across all devices?
    For accessing documents from all devices, a service like Dropbox is your best bet.
    I have no idea what "step as far away from an internet provider as possible" means. If you want Internet access, you need an Internet provider.
    Lighting fast speed for what? Processor? The specs are listed for all devices in the Online Store. Internet? We're back to the service provider.
    Technology changes. The only way to keep pace with it beyond a couple of years is to buy new stuff.
    The bottom line is you need to look at the specs for devices availble and at your budget and decide what best meets your needs. If you are unable to do that on your own, there are lot of technology consultants out there who will, for a fee, look at your exact situation, make recommendations and even handle the purchase and set up. Perhaps that would be the best route for you.
    Best of luck.

  • Please help me how to improve the performance of this query further.

    Hi All,
    Please help me how to improve the performance of this query further.
    Thanks.

    Hi,
    this is not your first SQL tuning request in this community -- you really should learn how to obtain performance diagnostics.
    The information you posted is not nearly enough to even start troubleshooting the query -- you haven't specified elapsed time, I/O, or the actual number of rows the query returns.
    The only piece of information we have is saying that your query executes within a second. If we believe this, then your query doesn't need tuning. If we don't, then we throw it away
    and we're left with nothing.
    Start by reading this blog post: Kyle Hailey &amp;raquo; Power of DISPLAY_CURSOR
    and applying this knowledge to your case.
    Best regards,
      Nikolay

  • I need help in understanding the customization of Landscape in R/3.

    I need help in understanding the customization of Landscape in R/3. Setup of SAP Landscape from an SAP SD point of view. Being as SAP SD consultant what would be my role in customizing the Landscape server. Help needed. Thx

    Hi,
    In a standard SAP project implementation, the 3 standard transport procedures are:
    Development System (DEV) --> QA System (QAS) --> Production System (PRD)
    In the above structure, the Training Client (TRN) could be made from the copy of PRD (after when real-time master data has been available) or from QA system (where configuration has been tested in DEV client, and the master data is uploaded manually for training purposes)
    Sandbox (standalone): This can be refreshed with Golden Client to reflect the latest configuration performed to facilitate the development/testing purposes.
    -Development (DEV): Where all system configurations and development activities are carried out.
    -Quality Assurance (QAS): Where functional testing is carried out. The System Integration Testing (carried out by the -Development Team) and the User Acceptance Testing (carried out by XXX appointed personnel) is carried out in this server.
    -Training (TRN): End Users are trained on this server.
    -Production (PRD): After the System is commissioned all data entry and administrative functions will be carried out in this server.
    This is by far the standard landscape architecture that is adopted and practiced in most implementations.
    Hope the above helps.
    Thanks.

  • I need help to remove the wrong email on my Iphone.  I can't down load app because my apple ID doese not match with the wrong email please help

    I need help to remove the wrong email on my Iphone.  the represnter who set up my phone put in the wrong email, and now I can't down loand apps on my phone because the apple ID does not match

    So sign out of the Apple ID under Settings > iTunes & App Store, then sign in with your own.

  • Need help to trace the place where error occuring in Web UI of type System

    Hi All,
    Need help to trace the place where error occurring in Web UI of type System error,
    this error coming while saving the corporate account creation,
    error message description : - System error: Interruption in Routine READ TABLE GT_CHAR_VAL, CHAR_NAME = PVTLTD_CLEAN_SEGMENT
    System error: Interruption in Routine READ TABLE GT_CHAR_VAL, CHAR_NAME = PVTLTD_CLEAN_CLASS-CP
    thanking you.
    Best Regards,
    VijHyd

    Hi Nagaraj,
    See that the mandatory SICF setting are enabled or Active in the SICF Services.  Follow the steps as below:-
    Enter the TCode SICF
    Execute the same for Hierarchy Type SICF.
    Check the following SAP Note 1295006.
    If every thing is Active then, the IC Agent role will open.
    Still if it is not opening Let me know.
    regards,
    Sarangamath

  • Need help in formatting the Date - Date does not

    Need help in formatting the Date - Date does not formats and give Not a valid month error in the below scenario.
    select oc.ST_PGM_MGR, r.ag_dnum, get_major_work_type(r.perf_eval_rtng_id) "v_work_code", r.ag_dnum_supp "supp", r.intfinal, to_char(r.formdate,'MM/DD/YYYY') "formdate", to_char(r.servfrom,'MM/DD/YYYY') "srv_from", to_char(r.servto,'MM/DD/YYYY') "srv_to", descript, add_months(to_char
    --- Bellow line of Code on trying to format it to mm/dd/yyyy gives the error
    (r.formdate, 'DD-MON-YYYY'),12) "formdate2"
    from  table REdited by: Lucy Discover on Jul 7, 2011 11:34 AM
    Edited by: Lucy Discover on Jul 7, 2011 1:05 PM

    Your syntax is wrong - look at the post above where this syntax is given:
    to_char (add_months(r.formdate,12), 'MM/DD/YYYY') "formdate2"Look at the formula from a logical perspective - "inside out" to read what is happening -
    take formdate, add 12 months
    add_months(r.formdate, 12)then apply the to_char format mask - basic syntax
    to_char(date, 'MM/DD/YYYY')Compare to your syntax:
    to_char(add_months(r.formdate, 'MM/DD/YYYY'),12) "formdate2"You will see your format string inside the call to add_months, and your 12 inside the call to to_char.
    Good luck!

  • Need help in understanding the error ORA-01843: not a valid month - ECX_ACT

    Hello All,
    We need help in understanding the Transaction Monitor -> Processing Message (error "ORA-01843: not a valid month - ECX_ACTIONS.GET_CONVERTED_DATE").
    And how to enable the log for Transaction Monitor -> Processing Logfile.
    Actually we are trying to import the Purchase Order XML (OAG) into eBusiness Suite via BPEL Process Manager using the Oracle Applications Adapter. The process is working fine with expected payload until it reaches the XML Gateway Transaction Monitor, where we are getting this error.
    thanks
    muthu.

    Hello All,
    We need help in understanding the Transaction Monitor -> Processing Message (error "ORA-01843: not a valid month - ECX_ACTIONS.GET_CONVERTED_DATE").
    And how to enable the log for Transaction Monitor -> Processing Logfile.
    Actually we are trying to import the Purchase Order XML (OAG) into eBusiness Suite via BPEL Process Manager using the Oracle Applications Adapter. The process is working fine with expected payload until it reaches the XML Gateway Transaction Monitor, where we are getting this error.
    thanks
    muthu.

  • Need help in optimisation for a select query on a large table

    Hi Gurus
    Please help in optimising the code. It takes 1 hr for 3-4000 records. Its very slow.
    My Select is reading from a table which contains 10 Million records.
    I am writing the select on large table and Retrieving the values from large tables by comparing my table which has 3-4 k records.
    I am pasting the code. please help
    Data: wa_i_tab1 type tys_tg_1 .
    DATA: i_tab TYPE STANDARD TABLE OF tys_tg_1.
    Data : wa_result_pkg type tys_tg_1,
    wa_result_pkg1 type tys_tg_1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1 from
    /BIC/PZREB_SDAT *******************THIS TABLE CONTAINS 10 MILLION RECORDS
    into CORRESPONDING FIELDS OF table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE***************CONTAINS 3000-4000 RECORDS
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE-/BIC/ZLITEM1.
    sort RESULT_PACKAGE by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    sort i_tab by AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1.
    loop at RESULT_PACKAGE into wa_result_pkg.
    read TABLE i_tab INTO wa_i_tab1 with key
    /BIC/ZREB_SDAT =
    wa_result_pkg-/BIC/ZREB_SDAT
    AGREEMENT = wa_result_pkg-AGREEMENT
    /BIC/ZLITEM1 = wa_result_pkg-/BIC/ZLITEM1.
    IF SY-SUBRC = 0.
    move wa_i_tab1-/BIC/ZSETLRUN to
    wa_result_pkg-/BIC/ZSETLRUN.
    wa_result_pkg1-/BIC/ZSETLRUN = wa_result_pkg-/BIC/ZSETLRUN.
    modify RESULT_PACKAGE from wa_result_pkg1
    TRANSPORTING /BIC/ZSETLRUN.
    ENDIF.
    CLEAR: wa_i_tab1,wa_result_pkg1,wa_result_pkg.
    endloop.

    Hi,
    1) RESULT_PACKAGE internal table contains any duplicate records or not bassed on the where condotion like below
    2) Remove the into CORRESPONDING FIELDS OF table instead of that into table use.
    refer the below code is
    RESULT_PACKAGE1[] = RESULT_PACKAGE[].
    sort RESULT_PACKAGE1 by /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    delete adjustant duplicate form RESULT_PACKAGE1 comparing /BIC/ZREB_SDAT AGREEMENT /BIC/ZLITEM1.
    SELECT /BIC/ZSETLRUN AGREEMENT /BIC/ZREB_SDAT /BIC/ZLITEM1
    from /BIC/PZREB_SDAT
    into table i_tab
    FOR ALL ENTRIES IN RESULT_PACKAGE1
    where
    /bic/ZREB_SDAT = RESULT_PACKAGE1-/BIC/ZREB_SDAT
    AND
    AGREEMENT = RESULT_PACKAGE1-AGREEMENT
    AND /BIC/ZLITEM1 = RESULT_PACKAGE1-/BIC/ZLITEM1.
    and one more thing your getting 10 million records so use package size in you select query.
    Refer the following link also For All Entry for 1 Million Records
    Regards,
    Dhina..
    Edited by: Dhina DMD on Sep 15, 2011 7:17 AM

  • I Need Help to Access The Source Code From A Form to Know the Calculation Formula

    Hi,
    I Need Help to Access The Source Code From A Form to Know the Calculation Formula. The application is a windows form application that is linked to SQL Server 2008. In one of the application forms it generates an invoice and does some calculations. I just
    need to know where behind that form is the code that's doing the calculations to generate the invoice, I just need to get into the formula that's doing these calculations.
    Thank you so much.

    Hi, 
    Thanks for the reply. This is a view and [AmountDue] is supposed to be [CurrentDueAmount] + [PastDueAmount] - [PaidAmount]. The view is not calculating [PaidAmount] right . Below is the complete code of the view. Do you see anything wrong in the code ?
    Thanks. 
    SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
    [iff].[FacilityFeeID], [LoanID] = NULL, [isi].[PortfolioID], [isi].[Portfolio], 
                          [PaymentType] = [isis_fee].[SectionType], [Name]
    = [iff].[Name], [ReceivedAmount], [dates].[CurrentDueAmount], 
                          [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount],
    0) > 0 THEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                          WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply reset to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN 0 ELSE [pastdue].[PastDueFeeAmount]
    + ISNULL([ReceivedAmount], 0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [pastdue].[PastDueFeeAmount] < 0 THEN 0 ELSE
    [pastdue].[PastDueFeeAmount] END, [PaidAmount] = CASE WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN - ([pastdue].[PastDueFeeAmount]
    + ISNULL([ReceivedAmount], 0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [pastdue].[PastDueFeeAmount] < 0 THEN - [pastdue].[PastDueFeeAmount]
    ELSE 0 END, [AmountDue] = [unpaid].[UnpaidFeeAmount], [ID] = [iff].[FacilityFeeID]
    FROM         [dbo].[INV_SubInvoice] isi JOIN
                          [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
    = [ii].[ID] JOIN
                          [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
    JOIN
                          [dbo].[INV_FacilityFee] iff ON [if].[ID] = [iff].[INV_FacilityID]
    JOIN
                              (SELECT     [sis_fee].[ID],
    [sis_fee].[SectionTypeCode], [SectionType] = [st_fee].[Name], [sis_fee].[INV_FacilityFeeID]
                                FROM      
       [dbo].[INV_SubInvoiceSection] sis_fee JOIN
                   [dbo].[INV_SectionType] st_fee ON [sis_fee].[SectionTypeCode] = [st_fee].[Code]
                                WHERE      [INV_FacilityFeeID]
    IS NOT NULL AND [StatusCode] = 'BILL') isis_fee ON [iff].[ID] = [isis_fee].[INV_FacilityFeeID] JOIN
                              (SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                   [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedFeeAmount]), 
                   [ReceivedAmount] = SUM([iffa].[ReceivedFeeAmount])
                                FROM      
       [dbo].[INV_FacilityFeeAccrual] iffa
                                GROUP BY [iffa].[SectionID])
    dates ON [isis_fee].[ID] = [dates].[SectionID] LEFT JOIN
                              (SELECT     *
                                FROM      
       [dbo].[INV_FacilityFeeAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                          [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
    LEFT JOIN
                              (SELECT     [SectionID],
    [PastDueFeeAmount] = SUM([PastDueFeeAmount])
                                FROM      
       [dbo].[INV_FacilityFeeAccrual]
                                GROUP BY [SectionID]) pastdue
    ON [dates].[SectionID] = [pastdue].[SectionID]
    UNION
    SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
    [FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio], 
                          [PaymentType] = [isis_loan].[SectionType], [Name]
    = [il].[Name], [ReceivedAmount], [CurrentDueAmount], [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount], 
                          0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount],
    0) WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
    0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
    END, 
                          [PaidAmount] = CASE WHEN [isis_loan].[SectionTypeCode]
    = 'LOAN_PRIN' THEN 0 ELSE CASE WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
    0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN - [PastDueAmount]
    ELSE 0 END END, 
                          [AmountDue] = CASE WHEN [isis_loan].[SectionTypeCode]
    = 'LOAN_PRIN' THEN [CurrentDueAmount] ELSE [unpaid].[AmountDue] END, [ID] = [il].[LoanID]
    FROM         [dbo].[INV_SubInvoice] isi JOIN
                          [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
    = [ii].[ID] JOIN
                          [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
    JOIN
                          [dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
    JOIN
                              (SELECT     [sis_loan].[ID],
    [sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
                                FROM      
       [dbo].[INV_SubInvoiceSection] sis_loan JOIN
                   [dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
                                WHERE      [INV_LoanID]
    IS NOT NULL AND [StatusCode] = 'BILL') isis_loan ON [il].[ID] = [isis_loan].[INV_LoanID] JOIN
                              (SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                   [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[ExpectedPrincipalAmount]), 
                   [ReceivedAmount] = SUM([ReceivedPrincipalAmount])
                                FROM      
       [dbo].[INV_LoanPrincipalAmortization] iffa
                                GROUP BY [iffa].[SectionID]
                                UNION
                                SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                  [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
                  [ReceivedAmount] = SUM([ReceivedInterestAmount])
                                FROM      
      [dbo].[INV_LoanCashInterestAccrual] iffa
                                GROUP BY [iffa].[SectionID]
                                UNION
                                SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                  [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
                  [ReceivedAmount] = SUM([ReceivedInterestAmount])
                                FROM      
      [dbo].[INV_LoanPIKInterestAccrual] iffa
                                GROUP BY [iffa].[SectionID])
    dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
                              (SELECT     [AmountDue]
    = [UnpaidPrincipalAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
       [dbo].[INV_LoanPrincipalAmortization]
                                UNION
                                SELECT     [AmountDue]
    = [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
      [dbo].[INV_LoanCashInterestAccrual]
                                UNION
                                SELECT     [AmountDue]
    = [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
      [dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                          [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
    LEFT JOIN
                              (SELECT     [PastDueAmount]
    = SUM([PastDuePrincipalAmount]), [SectionID]
                                FROM      
       [dbo].[INV_LoanPrincipalAmortization]
                                GROUP BY [SectionID]
                                UNION
                                SELECT     [PastDueAmount]
    = SUM([PastDueInterestAmount]), [SectionID]
                                FROM      
      [dbo].[INV_LoanCashInterestAccrual]
                                GROUP BY [SectionID]
                                UNION
                                SELECT     [PastDueAmount]
    = SUM([PastDueInterestAmount]), [SectionID]
                                FROM      
      [dbo].[INV_LoanPIKInterestAccrual]
                                GROUP BY [SectionID]) pastdue
    ON [dates].[SectionID] = [pastdue].[SectionID]
    UNION
    SELECT     [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
    [FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio], 
                          [PaymentType] = 'PIK Interest Applied', [Name]
    = [il].[Name], [ReceivedAmount], [CurrentDueAmount] = - [dates].[CurrentDueAmount], 
                          [PastDueAmount] = - CASE WHEN ISNULL([ReceivedAmount],
    0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
    0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
    END, [PaidAmount] = - CASE WHEN ISNULL([ReceivedAmount], 0) 
                          < 0 THEN /* We bring past due to zero and
    apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) 
                          < 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
    0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND 
                          [PastDueAmount] < 0 THEN - [PastDueAmount]
    ELSE 0 END, [AmountDue] = - [AmountDue], [ID] = [il].[LoanID]
    FROM         [dbo].[INV_SubInvoice] isi JOIN
                          [dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
    = [ii].[ID] JOIN
                          [dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
    JOIN
                          [dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
    JOIN
                              (SELECT     [sis_loan].[ID],
    [sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
                                FROM      
       [dbo].[INV_SubInvoiceSection] sis_loan JOIN
                   [dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
                                WHERE      [INV_LoanID]
    IS NOT NULL AND [StatusCode] = 'BILL' AND [sis_loan].[SectionTypeCode] = 'LOAN_INT_PIK') isis_loan ON 
                          [il].[ID] = [isis_loan].[INV_LoanID] JOIN
                              (SELECT     [iffa].[SectionID],
    [AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]), 
                   [AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]), 
                   [ReceivedAmount] = SUM([ReceivedInterestAmount])
                                FROM      
       [dbo].[INV_LoanPIKInterestAccrual] iffa
                                GROUP BY [iffa].[SectionID])
    dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
                              (SELECT     [AmountDue]
    = [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
                                FROM      
       [dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND 
                          [dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
    LEFT JOIN
                              (SELECT     [PastDueAmount]
    = SUM([PastDueInterestAmount]), [SectionID]
                                FROM      
       [dbo].[INV_LoanPIKInterestAccrual]
                                GROUP BY [SectionID]) pastdue
    ON [dates].[SectionID] = [pastdue].[SectionID]

  • I have tried everything I know to retrieve the iPhoto Library app.  I detest this new Photo app, which obviously wasn't designed with photographers in mind.  I desperately need help in retrieving the old app and have not been able to do it so far.

    I have tried everything I know to retrieve the iPhoto Library app.  I detest this new Photo app, which obviously wasn't designed with photographers in mind.  I desperately need help in retrieving the old app and have not been able to do it so far.  I have gone to my app folder and tried to update my iPhoto Library.  I have gone to my trash and brought it over to my desktop and still cannot use it.  Please help!

    Try this fix discovered by User photosb189:
    From Finder, hold down the option key on your keyboard and click on the Go menu at the top of the screen
    Select Library from the drop down menu
    Then navigate to Application Support > iLifeAssetManagement > assets
    Right click on the 'sub' folder and choose Compress
    Drag the resulting zip file to your Desktop (as a backup)
    Go to your System Preferences and choose iCloud
    Turn OFF the iCloud Photos option
    Go back to Library > Application Support and DELETE the iLifeAssetManagement folder
    Now, in System Preferences, turn the iCloud Photos option ON
    iPhoto should now be able to launch. Give it enough time to re-download your Photo Stream content. if you are missing any of your My Photo Stream photos (more than 30 days old), unzip the sub folder on your desktop and drag that into iPhoto.

Maybe you are looking for

  • Unable to edit the forms in Adobe Acrobat 9 Pro and adobe pdf reader.

    Hai ,     i am unable to edit pdf forms . on clicking on the form text field error message comes as "font capture" message heading and content as "C:\Windows\system32/ATMLIB.dll is either not designed to run on Windows or it contains an error. Try in

  • ITunes audio book download error message.

    I have purchased audio book "Thunder Below," by Eugene Fluckley  the purchase has been approved and completed by Credit card. I began downloading but now keep getting an error message saying cannot download at this time. System is up to date and with

  • I want to delete EVERYTHING about firefox

    i want to delete EVERYTHING about firefox. i uninstall, delete all the folders i can find, rummage through the registry, use lots of file cleaners and registry cleaners -- then when i reinstall firefox, it remembers my profiles and add-ons and all ki

  • IPod 5G Firewire Connection

    I know that 5G iPods don't support firewire connections, but is there any way to download, or do something to my ipod to make firewire work?

  • Rebuilding husband's credit! Help!

    Hello! Hoping for some advice on what we should do. Currently my husband owns the house that we live in (purchased in 2008, well before we got married). I have no ties to the house. We were going through a rough time financially for awhile. He was la