• Also if your data contains duplicate invoice dates as shown in the result set in your first post then you will need to use DENSE_RANK not ROW_NUMBER.

    Plus your two requirements in your last post are not compatible.

    Do you want to update all records with the rank or only update the first date?

    Is there a unique key on the table?

    Far away is close at hand in the images of elsewhere.
    Anon.