title: Assign variable value within select, among other columns
body: <p>I am aware that you can assign a value to a variable within a select by going</p>
  
  <pre><code>SELECT @blahBlah = (tbl.ProductGroup) 
  FROM tbl
  </code></pre>
  
  <p>Ok, now what I need to do is as follow.</p>
  
  <p>Each account/user has a set number of transactions allowed every day; eg. Account 1 can do 5 transactions and Account 2 can do 3.</p>
  
  <p>So in a select that will determine whether this account has overshot its limit and by how many, we have numerous <code>inSelect</code> calculations to produce column data. </p>
  
  <p>The problem is that we now have about 4 columns that will each do a nested select to get the limits from another table, in order to produce a value for the current one.</p>
  
  <p>What would be ideal is to assign these limits to a <code>@variable</code> in the select statement and to only reference that variable within said statement if needed.</p>
  
  <p>To give a brief example (not actual logic):</p>
  
  <pre><code>SELECT
    @Limit = (SELECT Limit From tClient Where tClient.clientId = tbl.ClientId),
    (select count(*) from batch where batchItemCount &gt; @limit) AS BadBatches,
    ....
  FROM TBL
  </code></pre>
  
  <p>You get the picture.</p>
  
  <p>Is there some method to pull this off?</p>