title: Select and count the same records
body: <p>In my Stored Procedure, I have two queries:</p>
  
  <p>Here rec_count is out parameter and cursor_name is in out parameter.</p>
  
  <pre><code>open cursor_name for
  select &lt;col list&gt; from &lt;table1 join table2 inner join...&gt; on &lt;join conditions&gt; where &lt;conditions&gt;;
  
  select count(*) into rec_count from &lt;table1 join table2 inner join...&gt; on &lt;join conditions&gt; where &lt;conditions&gt;;
  </code></pre>
  
  <ul>
  <li>Is there a way I can do the select and count together as I am providing the same join conditions and where clause again?</li>
  <li>Will this affect performance or SQL Optimizer will optimize these two queries?</li>
  </ul>