--CREATE DATABASE
CREATE DATABASE BMW_SALES;
--CHECK TABLE
SELECT *
FROM BMW_sales_dataset;
--TOTAL REVENUE PER REGION
SELECT region, SUM(Price_USD * sales_volume) AS total_revenue
FROM BMW_sales_dataset
GROUP BY region
ORDER BY SUM(Price_USD * sales_volume);

Insight: Asia generates the highest BMW revenue, indicating it’s the brand’s most profitable market. In contrast, Africa accounts for the smallest share, suggesting opportunities to optimize sales strategy or expand market penetration
--TOP 10 AUTOMATIC CARS BY HIGHEST TOTAL SALES
SELECT TOP 10 Year, SUM(Sales_Volume) AS Total_sold
FROM BMW_sales_dataset
WHERE Transmission = 'Automatic'
GROUP BY Year
ORDER BY SUM(Sales_Volume) DESC;

Insight: Automatic cars peaked in sales in 2019, indicating strong consumer preference for automatic transmission that year. This trend can inform production planning and inventory allocation for similar markets.
-- YEARS WITH THE HIGHEST REVENUE
SELECT TOP 10 Year, SUM(Price_USD * sales_volume) AS total_revenue
FROM BMW_sales_dataset
GROUP BY Year
ORDER BY SUM(Price_USD * sales_volume) DESC;

Insight: Total revenue peaked in 2022, reflecting strong market performance and possibly the success of new model launches or strategic marketing initiatives that year.
-- REGION REVENUE % CONTRIBUTION
SELECT region,
ROUND(SUM(price_usd * sales_volume) * 100.0 /
(SELECT SUM(price_usd * sales_volume) FROM BMW_sales_dataset), 2) AS revenue_share_pct
FROM BMW_sales_dataset
GROUP BY region
ORDER BY revenue_share_pct DESC;

Insight: Asia dominates revenue share, accounting for 17% of total sales, which underscores a bit strong market demand.
-- AVERAGE PRICE PER ENGINE SIZE
SELECT
CASE
WHEN ENGINE_SIZE_L < 2.0 THEN 'SMALL ENGINE'
WHEN ENGINE_SIZE_L BETWEEN 2.0 AND 3.0 THEN 'MEDIUM ENGINE'
ELSE 'LARGE ENGINE'
END AS ENGINE_SIZING,
AVG(Price_USD) AS AV_PRICE
FROM BMW_sales_dataset
GROUP BY CASE
WHEN ENGINE_SIZE_L < 2.0 THEN 'SMALL ENGINE'
WHEN ENGINE_SIZE_L BETWEEN 2.0 AND 3.0 THEN 'MEDIUM ENGINE'
ELSE 'LARGE ENGINE'
END
ORDER BY SUM(Price_USD) DESC;

Insight: Average prices across small, medium, and large engine sizes are very similar, suggesting BMW positions its models competitively regardless of engine capacity. This could indicate a strategy to focus on performance or features rather than price differentiation.
-- TOP 10 REGION AND MODEL SOLD (BY REVENUE)
SELECT TOP 10 region, model,
SUM(Price_USD * sales_volume) AS total_revenue
FROM BMW_sales_dataset
GROUP BY region, model
ORDER BY SUM(Price_USD * sales_volume) DESC;
