T-SQL How to update the bottom/last row only?
;WITH CTE AS
(
SELECT TOP 1 *
FROM @ResultTable
ORDER BY PeriodID DESC
)
UPDATE CTE SET PeriodLastDate=DATEADD(DAY,-1,PeriodLastDate)
There's not enough context in your question to give a bulletproof answer. Based on your working solution, how about instead of looking for the count look for the max PeriodID? As long as subsequent PeriodID's are a greater value it should work to get the "last" record.
UPDATE @ResultTable
SET PeriodLastDate=DATEADD(DAY,-1,PeriodLastDate)
WHERE PeriodID=(SELECT MAX(PeriodID) FROM @ResultTable)