SELECT ITEMID, DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) AS AGEDDAYS, (CASE WHEN QTY>0 THEN QTY ELSE 0 END) AS PURQTY, (CASE WHEN QTY<0 THEN qty ELSE 0 END) AS SALQTY, (CASE WHEN DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) < 0 THEN '0-Current' WHEN ( DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) > 0 AND DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) <= 30 ) THEN '1-0-30 Days' -- 1 month WHEN ( DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) > 30 AND DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) <= 60 ) THEN '2-31-60 Days' -- 2 months WHEN ( DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) > 60 AND DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) <= 90 ) THEN '3-61-90 Days' -- 3 months WHEN ( DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) > 90 AND DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE) <= 180 ) THEN '4-91-180 Days' -- 6 months WHEN ( DATEDIFF(day, INVENTTRANS.DATEPHYSICAL, @TODATE)...