Performant way to get the maximum value of a running total in TSQL
问题 We have a table of transactions which is structured like the following : TranxID int (PK and Identity field) ItemID int TranxDate datetime TranxAmt money TranxAmt can be positive or negative, so the running total of this field (for any ItemID) will go up and down as time goes by. Getting the current total is obviously simple, but what I'm after is a performant way of getting the highest value of the running total and the TranxDate when this occurred. Note that TranxDate is not unique, and due