title: How to create a ratio using Temp variables and Temp Tables
body: <p>I am trying to create a ratio to determine a decline rate.</p>
  
  <p>I have created two temp tables and Stored the correct information inside them. What I need now Is a ratio created from the two temp tables </p>
  
  <p>I need to create a ratio from the two temp tables and store it inside the <code>@DECLINERATE</code> variable. Then use this ratio to <code>order by</code></p>
  
  <p>I have tried to do the calculation within the <code>select</code> part of the statement for the two temp tables, Which I believe is possible I just cant seem to get it working</p>
  
  <p>Here  is the part i'm struggling with: </p>
  
  <pre><code>DECLARE @DECLINERATE INT;
  SET @DECLINERATE =  (SELECT (t2.[Number Of Individual Sales] / t1.[Number Of Individual Sales] * 100) as [Decline RATIO]
      FROM #TempTbl12MonthDecline1 t1 
      join #TempTbl12MonthDecline2 t2 on 
      t1.[Number Of Individual Sales] = t2.[Number Of Individual Sales] )
  </code></pre>
  
  <p>I'm expecting to get a ratio that is created from <code>[AMOUNT OF INDIVIDUAL SALES]</code>  of both the temp tables. However, I am currently receiving error when executing code posted:</p>
  
  <blockquote>
    <p>Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, &lt;, &lt;= , >, >= or when the subquery is used as an expression.</p>
  </blockquote>