title: How to group by a Calculated Field
body: <p>I need to group by a Calculated field ins SQL Server 2005/2008.</p>
  
  <p>I have the following sql:</p>
  
  <pre><code>select dateadd(day, -7, Convert(DateTime, mwspp.DateDue) + (7 - datepart(weekday, mwspp.DateDue))),
  sum(mwspp.QtyRequired)
  from manufacturingweekshortagepartpurchasing mwspp
  where mwspp.buildScheduleSimID = 10109 and mwspp.partID = 8366
  group by mwspp.DateDue
  order by mwspp.DateDue
  </code></pre>
  
  <p>Instead of <code>group by mwspp.DateDue</code> I need to group by the result of the calculation. Is it possible ?</p>
  
  <p>Thanks in advance</p>