I need your help finding a better solution to my select statement. In the Month1 expression, I reference DueDate to place sum of units in Month1 bracket. My query requires the DueDate to be part of the group which is not the desired result.
Results show groups of the sum units for each DueDate.
(CASE WHEN (SUBSTRING((DueDate),5,2)<=MONTH(CURRENT_DATE) and (LEFT((DueDate),4))<=YEAR(CURRENT_DATE)) THEN SUM(UNITS) ELSE 0 END) as Month1
GROUP BY Style, Color, DueDate