title: How to assign a sum of values within fields to a variable?
body: <p>I have an SQL statement which selects various data from a table in my database and I have declared variables within my code like:</p>
  
  <pre><code>DECLARE @TotalAge int;
  </code></pre>
  
  <p>Let's say one of the fields in the table is <code>Age</code>, how would I sum the collected values from the query and assign them to the variable as a total?</p>