How to calculate percentage with a SQL statement
I have a similar question to this except for revenue. A corporation has a region (east west central) and a revenue
I've aggregated the regions but i'm having trouble dealing with the percents, this is what i have so far
- Summary of revenues by region (in ranked order from highest to lowest, calculate % of total for each region)
here's my code so far
SELECT Region, Sum(revenue) AS TotalRevenue
FROM Sales
GROUP BY Region
ORDER BY Sum(revenue) DESC;
i've also tried
SELECT Sales.Region, Sales.Sales.[*] AS Expr1
FROM Sales
GROUP BY Sales.Sales.[*], Sales;
i'm still very confused
I tried this code, and it worked SELECT Region , Sum(revenue) AS TotalRevenue , Sum(revenue) / (SELECT SUM(revenue) FROM Sales) * 100 AS percentage FROM Sales GROUP BY Region ORDER BY Sum(revenue) DESC;
Now, there's another part
For the region with the smallest revenue, show the products by revenue and % of regional sales For the region with the smallest revenue, show the customers list ranked by revenue and % of regional sales and then I have to prepare graphs or talbes to summarize my findings in excel should i just copy and paste my data into excel or link it to excel/import it into excel? if i need to do that ,how would i do that? thanks