I have an SQL statement which selects various data from a table in my database and I have declared variables within my code like:
DECLARE @TotalAge int;
Let’s say one of the fields in the table is Age, how would I sum the collected values from the query and assign them to the variable as a total?
First set
@TotalAge:then select
@TotalAgewhere you want: