• Based on the query alone, I don't see where to put either a SUM or a COUNT (and it could be either depending on your structure). How is an item identified, or, where within what you're showing is the count of items in a transaction? If the items are individually listed, then probably a COUNT is the way to go. If there is already a count of items within a transaction, then SUM would be your answer.

    But where exactly within that hot mess it goes? Not a clue.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning