Results 1 to 6 of 6

Thread: Query for tertial (4 month)

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    3

    Query for tertial (4 month)

    Hi Geeks

    This is my first post and i hope to recieve a relevent answers from the experts here

    we have recently transition from quaters to tertials and there is a job which counts all the calls made by rep every qyater (Calls QTD).

    this has to change now to tertial but there is no standard function in oracle for tertial.
    statement that needs to be changed here is AND T2.APPT_START_DT >= to_date(trunc(sysdate,'Q')) (Query Below)

    Please help!!

    T1.PERSON_UID,
    PT1.NAME POSTN_NAME,
    G1.X_AZ_LAST_CALL_DT,
    G2.X_AZ_CALLS_QTD,
    G3.X_MY_CALLS_QTD
    FROM SIEBEL.S_CONTACT T1,
    SIEBEL.S_POSTN_CON C1,
    SIEBEL.S_POSTN PT1,
    SIEBEL.S_CONTACT E1,
    ( SELECT /*+ INDEX(T2 S_EVT_ACT_CALL_X) */
    T2.TARGET_PER_ID,
    MAX(APPT_START_DT)
    as X_AZ_LAST_CALL_DT
    FROM SIEBEL.S_EVT_ACT T2
    WHERE T2.SUBTYPE_CD ='Professional Call'
    AND T2.EVT_STAT_CD ='Submitted'
    AND T2.APPT_START_DT >= to_date(trunc(sysdate,'Q'))
    GROUP BY T2.TARGET_PER_ID ) G1,
    (SELECT /*+ INDEX(T2 S_EVT_ACT_CALL_X1) */
    T2.TARGET_PER_ID, COUNT(T2.ROW_ID) as X_AZ_CALLS_QTD
    FROM SIEBEL.S_EVT_ACT T2
    WHERE T2.SUBTYPE_CD ='Professional Call'
    AND T2.EVT_STAT_CD ='Submitted'
    AND T2.APPT_START_DT >= to_date(trunc(sysdate,'Q'))
    AND T2.TODO_CD ='1-1 Call'
    GROUP BY T2.TARGET_PER_ID) G2,
    (SELECT /*+ INDEX(T2 S_EVT_ACT_CALL_X) */ T2.TARGET_PER_ID,
    T3.EMP_ID, COUNT(T3.ROW_ID) AS X_MY_CALLS_QTD
    FROM SIEBEL.S_EVT_ACT T2, SIEBEL.S_ACT_EMP T3
    WHERE T2.ROW_ID = T3.ACTIVITY_ID
    AND T2.SUBTYPE_CD ='Professional Call'
    AND T2.EVT_STAT_CD ='Submitted'
    AND T2.APPT_START_DT >= to_date(trunc(sysdate,'Q'))
    AND T2.TODO_CD ='1-1 Call'
    GROUP BY T2.TARGET_PER_ID,T3.EMP_ID) G3
    WHERE T1.ROW_ID = C1.CON_ID
    AND G3.EMP_ID = E1.ROW_ID
    AND E1.PR_HELD_POSTN_ID = PT1.ROW_ID
    AND PT1.ROW_ID = C1.POSTN_ID
    AND T1.ROW_ID = G1.TARGET_PER_ID
    AND T1.ROW_ID = G2.TARGET_PER_ID
    AND T1.ROW_ID = G3.TARGET_PER_ID


  2. #2
    Moderator
    Join Date
    Jun 2007
    Answers
    2,074

    Re: Query for tertial (4 month)

    What is the problem with this query and what exactly you are trying to do ?


  3. #3
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Query for tertial (4 month)

    Try using the following method
    select case when to_char(trunc(sysdate),'mm') between '01' and '04' then '01-01-'||to_char(sysdate,'yyyy')
    when to_char(trunc(sysdate),'mm') between '05' and '08' then '01-05-'||to_char(sysdate,'yyyy')
    when to_char(trunc(sysdate),'mm') between '09' and '12' then '01-09-'||to_char(sysdate,'yyyy') end case
    from dual


  4. #4
    Junior Member
    Join Date
    Apr 2008
    Answers
    3

    Re: Query for tertial (4 month)

    Quote Originally Posted by debasisdas View Post
    What is the problem with this query and what exactly you are trying to do ?
    Hi Ya

    the problem is we cant use T2.APPT_START_DT >= to_date(trunc(sysdate,'Q')) as it will be calculating 3 months but we want to filter it for 4 monthly

    Cheers!!


  5. #5
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Query for tertial (4 month)

    use
    last_day(to_date(trunc(sysdate,'Q')))+1 or last_day(to_date(trunc(sysdate,'Q')))


  6. #6
    Junior Member
    Join Date
    Apr 2008
    Answers
    3

    Re: Query for tertial (4 month)

    Thank you very much , this solved the purpose .


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact