Skip to main content

Command Palette

Search for a command to run...

8 Week SQL Challenge - Case Study 5 (Data Exploration)

Updated
1 min read
M
Mary has been writing about Data Science on her blog (http://maryjonah.me) for years. In her free time, she likes to read books and have a good rest.

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;