Cognos Analytics

Cognos Analytics

Connect, learn, and share with thousands of IBM Cognos Analytics users! 

 View Only
  • 1.  Framework Manager - Add a select statement within a left join filter

    Posted Tue February 02, 2021 12:20 PM

    I have the following sql in which I am trying to determine how to define it in framework manager to filter the left join.  I am particularly wondering how or where to create the select statement so that I can do the =  compare for sign.Update_date.

     

     left join dbo.sign sign ON t.person_id = sign.person_id and t.posting_date = sign.post_date

                                                      and sign.Update_date = (select max(s.update_date)

                                                                                    from dbo.sign s

                                                                                     where t.person_id = s.person_id

                                                                                     and t.posting_date = s.post_date

                                                                                     and s.sign_state_flag = 1

                                                                                     )

    Any suggestions on how to write the (select max section) within the expression definition so that I can compare to get the max date record to filter the join?
    #CognosAnalyticswithWatson


  • 2.  RE: Framework Manager - Add a select statement within a left join filter

    Posted Wed February 03, 2021 09:23 AM

    Towandra Grant – there are two possible ways I can think of this early in the morning, I am sure there are others:

    -       Native SQL – this is not preferred for many reasons, but sometimes it is the only way to do it, but can potentially make code harder to maintain and not as portable

    -       Create a merge query subject between two child query subjects, the join will be a left outer join between the two child queries

     

    Hope this helps.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Peter Chan

    613-295--0428

     






  • 3.  RE: Framework Manager - Add a select statement within a left join filter

    Posted Wed February 03, 2021 03:43 PM
    Thank you Peter for your suggestions.

     What I did was:

    1. Within the Sign table query subject definition, I changed the SQL Settings to Native (as you suggested)
    2. I then manually wrote the Select statement in which I added a subquery to create the new query item max_update_date
    3. Now that the new max_update_date query subject was created on the sign table, I was able to go into the Relationship Editor for my join
    4.  and manually (using the expression editor) include the condition where sign_update_date = max_update_date.
    **Although using Native SQL is not ideal, this method did render the results that I needed for a more complex join that Cognos was not able to (easily) handle.
    (At least, not that I know of)  Always open to learning new things and new ways of accomplishing a common goal.

    ------------------------------
    Towandra Grant
    ------------------------------



  • 4.  RE: Framework Manager - Add a select statement within a left join filter

    Posted Mon February 08, 2021 06:05 PM
    Hi Towandra,
    Another method, may be a bit easier to maintain.
    Query Subject Sign (or a copy/alias of it)
    Add an embedded filter:   [update_date] = maximum ([update_date] for [person_id] , [post_date] )
    and another one: [sign_state_flag] = 1

     
    The relationship to this would need to have a 0:N cardinality or 0:1, so that it is a left outer join.                                                                      

    // Henk



    ------------------------------
    HENK CAZEMIER
    ------------------------------



  • 5.  RE: Framework Manager - Add a select statement within a left join filter

    Posted Tue February 09, 2021 08:59 AM

    I just wanted to add my US$0.02 to this thread. 

    We've had a LOT of issues over the years (used Cognos since Decision Stream 7) when creating our packages in FM if we use too *fancy* of SQL when creating those packages.  Especially later on as the and the underlying database tables (Sybase) grow column-wise and row-wise we'd regularly run into situations where the final SQL generated by Cognos by the report would be terrible performance-wise.

    This has been continually getting worse as we migrate to later and later versions of Cognos.  We're on 11.1.5 now and it's worse than 11.0.12/13 which was FAR worse than 10.2.2. 

    We've been rewriting the SQL especially those with 3-4 table joins and putting all that logic into a View in the database.  Then to FM/Cognos it just looks like a simple table.  Has made a HUGE improvement and honestly makes work in FM a lot simpler too.  That's the best way we've found to get good, consistent results across our packages and reports.

    Wayne



    ------------------------------
    Wayne Westlake
    ------------------------------