• I'm on version 2000 which is probably why I generated these errors when I tried to run your code. The good news is that SQL admin people are trying to get me access to another database that is 2008. Actually, I am running Management Studio 2008.

    Msg 156, Level 15, State 1, Line 2

    Incorrect syntax near the keyword 'with'.

    Msg 195, Level 15, State 10, Line 4

    'ROW_NUMBER' is not a recognized function name.

    The data set I sent still does not have "N" for non-risk in the RiskNonRiskFlag column but I think you have already corrected that. I think we may have to sort on serial number as well as DeliveryDate but we are so close.