8 Week SQL Challenge - Case Study 5 (Data Exploration)
Here we go with responses to questions in the second focus area: 2. Data Exploration of Case Study #5 - Data Mart
What day of the week is used for each week_date value?
SELECT
DISTINCT DAYNAME(week_date)
FROM clean_weekly_sales;
How many total transactions were there for each year in the dataset?
SELECT
calendar_year,
COUNT(*) AS total_transactions
FROM clean_weekly_sales
GROUP BY calendar_year;
What is the total sales for each region for each month?
SELECT
region,
MONTH(STR_TO_DATE(week_date, '%d/%m/%y')) AS month_number,
SUM(sales) AS total_sales_per_region_per_month
FROM weekly_sales
GROUP BY region, MONTH(STR_TO_DATE(week_date, '%d/%m/%y'))
ORDER BY region, month_number;
What is the total count of transactions for each platform
SELECT
platform,
SUM(transactions) AS transactions_per_platform
FROM weekly_sales
GROUP BY platform;