SQL Server 9.0.3068

I'm doing some calculations and aggregations on data in my query and I'd like to reuse the results in other calculations. Ex.: ReservesWithheld and DistributionPercentage below.

Instead of redoing the calculations when I want to use DistributionPercentage, I've done them in a CTE and then "reused" them in the query after the CTE. Is it acceptable to proceed like this with a CTE so I can again reference the aliases or is there a better way to do this? How is this approach performance wise?

sql Code:
  1. use SalesData;
  2. go
  3. with SMSales as
  4. (
  5.     select
  6.         s.JournalRef Period,
  7.         s.ItemNumber,
  8.         s.ItemDescription,
  9.         s.CustomerNumber,
  10.         s.CustomerName,
  11.         sum(s.GrossQuantity) GrossUnits,
  12.         sum(s.ReturnQuantity) ReturnUnits,
  13.         sum(s.GrossAmount) GrossSales,
  14.         sum(s.GrossAmount) * .3 ReservesWithheld,
  15.         sum(s.ReturnAmount) ReturnSales,
  16.         case
  17.             when s.CustomerNumber = '0007520' or s.CustomerNumber = '6005019' or sum(s.GrossQuantity) = 0 then .1
  18.             when sum(s.GrossAmount) / sum(s.GrossQuantity) > 5 then 0.15
  19.             else .1
  20.         end as DistributionPercentage
  21.     from dbo.SalesByItem s
  22.     where
  23.         s.JournalRef = 'GPE_200903LM'
  24.     group by
  25.         s.JournalRef,
  26.         s.ItemNumber,
  27.         s.ItemDescription,
  28.         s.CustomerNumber,
  29.         s.CustomerName
  30. )
  31. select
  32.     sm.Period,
  33.     sm.ItemNumber,
  34.     sm.ItemDescription,
  35.     sm.CustomerNumber,
  36.     sm.CustomerName,
  37.     sm.GrossUnits,
  38.     sm.ReturnUnits,
  39.     sm.GrossUnits + sm.ReturnUnits NetUnits,
  40.     sm.GrossSales,
  41.     sm.ReservesWithheld,
  42.     sm.ReturnSales,
  43.     sm.GrossSales - sm.ReservesWithheld + sm.ReturnSales NetSales,
  44.     case
  45.         when sm.GrossUnits = 0 then 0
  46.         else sm.GrossSales / sm.GrossUnits
  47.     end as AvgWholesalePrice,
  48.     sm.DistributionPercentage,
  49.     (sm.GrossSales - sm.ReservesWithheld + sm.ReturnSales) * sm.DistributionPercentage DistributionFee
  50. from SMSales sm
  51. go