title: Different Group By Clause on same Query (Select/Where)
body: <p>Can i reuse a complex select Where clause to different group by?</p>
  
  <p>What i am doing:</p>
  
  <pre><code>(Select X, Count(*) From [Big where clause with many tables] Group By X)
  Union All
  (Select Y, Count(*) From [Big where clause with many tables] Group By Y)
  </code></pre>
  
  <p>How can i optmise this? </p>
  
  <p>I'm using SQL Server 2008 and this will go inside a Function, but could be a stored procedure.</p>