I was messing around in SQL and I stumbled onto this code mostly by accident and for reasons I can't explain works at least in SQL Server 2008.
I wouldn't normally ask this on SO but I don't what I should be searching for, and I was hoping to find out.
DECLARE @Number INT = 1
SELECT @Number = @Number + N
FROM (SELECT * FROM (VALUES (2), (3), (4)) vals(N)) vals
PRINT @Number
This adds 1 + 2 +3 + 4 and produces 10.
Why does this work and does this pattern have a name? Is it an anti-pattern?