For each quarter, compute the percentage of sales due to each product type.

This query requires inter-statement use of information. To compute the sales of a given product as a percentage of total sales for a given quarter, the quarterly totals must be computed and stored so that calculations for quarter/product pairs can retrieve the corresponding quarterly total.

DEFINE QuarterTotals AS
SELECT SUM(Amount) AS Total
GROUP BY Quarter ;

RETURN ProductPcts AS
SELECT 
  100 * SUM(Amount) / QuarterTotals[Quarter].Total AS PctTotal
GROUP BY Quarter, ProductType


Copyright © Legal Notices