title: Setting an SQL Query AS a variable or parameter (Integer prefered) and using it
body: <p>I couldn't solve that mistery question in <strong>SQL SERVER</strong>. </p>
  
  <p>Here an example that I tried to do and it didn't work.</p>
  
  <pre><code>DECLARE @Total int;
  SET @Total = (SELECT COUNT(*)-10 FROM MYTABLE)
  
  SELECT TOP @Total IdColumn FROM MYTABLE
  </code></pre>
  
  <p>How can I use the following query </p>
  
  <p>SELECT COUNT(*)-10 FROM MYTABLE</p>
  
  <p>as an integer variable, somewhere else in my code.</p>