• You seem to get Model_Id from a window and pass it up to an outer window, and that value does not get used in a filter, join or select on the last outer window.

    Not going to check all columns.

    Also, you are distincting a distinct of a distinct left joined to a distinct ansi-89 join distinct inside which is a ansi89 join again.

    try writing your joins first so that you can build the relationships between the tables.

    Don't window a select onto a table and bring back all columns. Just do a join directly on the table in the outer query.

    Windowing here looks to serve no purpose.

    Are you using a tool to create this query?

    Catch-all queries done right [/url]
    Gail Shaw's Performance Blog[/url]