Results 1 to 6 of 6

Thread: Business Objects Query...

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    2

    Business Objects Query...

    I have a number of rows per record with different create dates and activity logs (both in seperate columns). How would I be able to only select the activity log with the latest create date?

    Cheers.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Business Objects Query...

    Welcome to the forum

    Basically a query like this would accomplish what you want.

    Code:
    Select * From SomeTable T1
       Where T1.DateCreated=(Select Max(T2.DateCreated)
                                          From SomeTable T2
                                          Where T2.ActivityLog=T1.ActivityLog)
    The sub-query pulls the latest date created - and the main query uses that in the where clause.

    The where clause in the sub-query is needed to pull the DateCreated from the right set of associated rows.

    If you gave us your actual table name and column names - and also told us the database you are using - we could be a lot more specific with our answers.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2008
    Posts
    2

    Re: Business Objects Query...

    Hi - thanks for the welcome. The existing SQL is as below if this helps? It's written with Business Objects, the problem is that I don't know how to pick out the lastest activity log as they are each returned on individual rows?

    Thanks for the help!
    Code:
    SELECT
      TKT_TT_MAIN.TT_ID,
      STK_BOB_DATE(TKT_TT_MAIN.Ora_Fault_Start_Time),
      STK_BOB_DATE(TKT_TT_MAIN.Ora_Fault_Resolvee_Time),
      TKT_TT_MAIN.Impact,
      TKT_TT_MAIN.Priority,
      TKT_TT_MAIN.Manager_Group,
      TKT_TT_MAIN.Assignee_Group,
      TKT_TT_MAIN.CTI_Category,
      TKT_TT_MAIN.CTI_Type,
      STK_BOB_DATE(TKT_FLW_WORKLOG.Create_Date),
      TKT_TT_MAIN.CTI_Item,
      TKT_FLW_WORKLOG.Truncated_Work_Log
    FROM
      TKT_TT_MAIN,
      TKT_FLW_WORKLOG
    WHERE
      ( TKT_FLW_WORKLOG.TT_ID(+)=TKT_TT_MAIN.TT_ID  )
      AND  (
      TKT_TT_MAIN.TT_ID  =  @variable('Enter STK ID')
      )
    Last edited by si_the_geek; Dec 9th, 2008 at 10:07 AM. Reason: added code tags

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Business Objects Query...

    (+)=??

    This must not be MS SQL - what is the backend DB??

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Business Objects Query...

    I could be wrong, but I think that is Oracle syntax for an Outer Join.

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Business Objects Query...

    I'm not sure what fields the OP would use - and that SELECT that's shown didn't make it any clearer to me...

    My query should work in ORACLE as well - it's just not using the right WHERE clause in the sub-query (I'm guessing).
    Last edited by szlamany; Dec 10th, 2008 at 06:54 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width