Hey Guys,
I have a table caled "Sales":
I wrote a query that returns the total sales in the sports and music departments in the first 3 months of 2016:
SELECT COUNT (*) AS TOTAL_SALES, Department
FROM Sales
WHERE DATE >= '2016-01-01'
AND DATE < '2016-04-01'
AND DEPARTMENT IN ('MUSIC','SPORT')
GROUP BY Department
But now I want to calculate the their relative percentage (MUSIC&SPORT) out of the department's total sales.
I know that I need to calculate it this way, but It returns me an error:
CAST((CAST(COUNT(TOTAL_SALES_MUSIC_2016_Q1) AS FLOAT) / CAST(COUNT(TOTAL_SALES_MUSIC_2016) AS FLOAT) *100) AS VARCHAR) + '%' AS cnv_rate
Thanks,
Michal