• Chris Harshman - Wednesday, August 23, 2017 3:20 PM

    What are the indexes on the table DDA_TRAN?  It looks like it might make more sense to have an index that starts with the 2 join columns, with maybe the date being the third column, so (INSTITUTION_NUMBER, DDA_ACCOUNT, TRAN_DATE). 

    Similarly on DDA_DESC, (INSTITUTION_NUMBER, DDA_ACCOUNT, DESCRIPTION_LINK).

    A couple other things, the expression:
    ,RIGHT ('00' + LTRIM(RTRIM(STR(MONTH("DDA_TRAN"."POSTED_DATE")))), 2) + '/'
        + RIGHT('00' + LTRIM(RTRIM(STR(DAY("DDA_TRAN"."POSTED_DATE")))), 2) + '/'
        + LTRIM(RTRIM(STR(YEAR("DDA_TRAN"."POSTED_DATE"))))

    can probably be replaced by the much simpler:
    ,CONVERT(varchar(20), "DDA_TRAN"."POSTED_DATE", 101)

    And much of the processing seems to be to support the very complex GROUP BY clause, can that be simplified?

    Thanks Chris for the help.