I am using rollup to sum a table containing fields company, sales, cost and margin. This gives me the summarized columns, but I need to show a summarized percentage of the margin as a percentage of sales for each company summary.
This is my current statement:
SELECT coalesce(CAST(Company AS VARCHAR(30)), 'Grand Total:') AS Company,
SUM(Sales) AS 'TOTSALES',
SUM(CostVal) AS 'TOTCOST',
SUM(MarginVal) AS 'TOTMAR'
FROM DailySalesSum
GROUP BY Company WITH ROLLUP;
Do as Martin says and add it as an extra field to your statement as shown above.