<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.3">Jekyll</generator><link href="http://www.8weeksqlchallenge.com/feed.xml" rel="self" type="application/atom+xml" /><link href="http://www.8weeksqlchallenge.com/" rel="alternate" type="text/html" /><updated>2023-11-27T11:04:41+00:00</updated><id>http://www.8weeksqlchallenge.com/feed.xml</id><title type="html">8 Week SQL Challenge</title><subtitle>Start your SQL learning journey today!</subtitle><author><name>Danny Ma</name></author><entry><title type="html">Case Study #8 - Fresh Segments</title><link href="http://www.8weeksqlchallenge.com/case-study-8/" rel="alternate" type="text/html" title="Case Study #8 - Fresh Segments" /><published>2021-07-09T00:00:00+00:00</published><updated>2021-07-09T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-8</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-8/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/8.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Danny created Fresh Segments, a digital marketing agency that helps other businesses analyse trends in online ad click behaviour for their unique customer base.&lt;/p&gt;

&lt;p&gt;Clients share their customer lists with the Fresh Segments team who then aggregate interest metrics and generate a single dataset worth of metrics for further analysis.&lt;/p&gt;

&lt;p&gt;In particular - the composition and rankings for different interests are provided for each client showing the proportion of their customer list who interacted with online assets related to each interest for each month.&lt;/p&gt;

&lt;p&gt;Danny has asked for your assistance to analyse aggregated metrics for an example client and provide some high level insights about the customer list and their interests.&lt;/p&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;For this case study there is a total of 2 datasets which you will need to use to solve the questions.&lt;/p&gt;

&lt;h3 id=&quot;interest-metrics&quot;&gt;Interest Metrics&lt;/h3&gt;

&lt;p&gt;This table contains information about aggregated interest metrics for a specific major client of Fresh Segments which makes up a large proportion of their customer base.&lt;/p&gt;

&lt;p&gt;Each record in this table represents the performance of a specific &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id&lt;/code&gt; based on the client’s customer base interest measured through clicks and interactions with specific targeted advertising content.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;_month&lt;/th&gt;
        &lt;th&gt;_year&lt;/th&gt;
        &lt;th&gt;month_year&lt;/th&gt;
        &lt;th&gt;interest_id&lt;/th&gt;
        &lt;th&gt;composition&lt;/th&gt;
        &lt;th&gt;index_value&lt;/th&gt;
        &lt;th&gt;ranking&lt;/th&gt;
        &lt;th&gt;percentile_ranking&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;32486&lt;/td&gt;
        &lt;td&gt;11.89&lt;/td&gt;
        &lt;td&gt;6.19&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;99.86&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;6106&lt;/td&gt;
        &lt;td&gt;9.93&lt;/td&gt;
        &lt;td&gt;5.31&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;99.73&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;18923&lt;/td&gt;
        &lt;td&gt;10.85&lt;/td&gt;
        &lt;td&gt;5.29&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;99.59&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;6344&lt;/td&gt;
        &lt;td&gt;10.32&lt;/td&gt;
        &lt;td&gt;5.1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;99.45&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;100&lt;/td&gt;
        &lt;td&gt;10.77&lt;/td&gt;
        &lt;td&gt;5.04&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;99.31&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;69&lt;/td&gt;
        &lt;td&gt;10.82&lt;/td&gt;
        &lt;td&gt;5.03&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;99.18&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;79&lt;/td&gt;
        &lt;td&gt;11.21&lt;/td&gt;
        &lt;td&gt;4.97&lt;/td&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;99.04&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;6111&lt;/td&gt;
        &lt;td&gt;10.71&lt;/td&gt;
        &lt;td&gt;4.83&lt;/td&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;98.9&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;6214&lt;/td&gt;
        &lt;td&gt;9.71&lt;/td&gt;
        &lt;td&gt;4.83&lt;/td&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;98.9&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;19422&lt;/td&gt;
        &lt;td&gt;10.11&lt;/td&gt;
        &lt;td&gt;4.81&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;98.63&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;For example - let’s interpret the first row of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_metrics&lt;/code&gt; table together:&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;_month&lt;/th&gt;
        &lt;th&gt;_year&lt;/th&gt;
        &lt;th&gt;month_year&lt;/th&gt;
        &lt;th&gt;interest_id&lt;/th&gt;
        &lt;th&gt;composition&lt;/th&gt;
        &lt;th&gt;index_value&lt;/th&gt;
        &lt;th&gt;ranking&lt;/th&gt;
        &lt;th&gt;percentile_ranking&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2018&lt;/td&gt;
        &lt;td&gt;07-2018&lt;/td&gt;
        &lt;td&gt;32486&lt;/td&gt;
        &lt;td&gt;11.89&lt;/td&gt;
        &lt;td&gt;6.19&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;99.86&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;In July 2018, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;composition&lt;/code&gt; metric is 11.89, meaning that 11.89% of the client’s customer list interacted with the interest &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id = 32486&lt;/code&gt; - we can link &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id&lt;/code&gt; to a separate mapping table to find the segment name called “Vacation Rental Accommodation Researchers”&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index_value&lt;/code&gt; is 6.19, means that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;composition&lt;/code&gt; value is 6.19x the average composition value for all Fresh Segments clients’ customer for this particular interest in the month of July 2018.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ranking&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;percentage_ranking&lt;/code&gt; relates to the order of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index_value&lt;/code&gt; records in each month year.&lt;/p&gt;

&lt;h3 id=&quot;interest-map&quot;&gt;Interest Map&lt;/h3&gt;

&lt;p&gt;This mapping table links the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id&lt;/code&gt; with their relevant interest information. You will need to join this table onto the previous &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_details&lt;/code&gt; table to obtain the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_name&lt;/code&gt; as well as any details about the summary information.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;id&lt;/th&gt;
        &lt;th&gt;interest_name&lt;/th&gt;
        &lt;th&gt;interest_summary&lt;/th&gt;
        &lt;th&gt;created_at&lt;/th&gt;
        &lt;th&gt;last_modified&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Fitness Enthusiasts&lt;/td&gt;
        &lt;td&gt;Consumers using fitness tracking apps and websites.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;Gamers&lt;/td&gt;
        &lt;td&gt;Consumers researching game reviews and cheat codes.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Car Enthusiasts&lt;/td&gt;
        &lt;td&gt;Readers of automotive news and car reviews.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Luxury Retail Researchers&lt;/td&gt;
        &lt;td&gt;Consumers researching luxury product reviews and gift ideas.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Brides &amp;amp; Wedding Planners&lt;/td&gt;
        &lt;td&gt;People researching wedding ideas and vendors.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;Vacation Planners&lt;/td&gt;
        &lt;td&gt;Consumers reading reviews of vacation destinations and accommodations.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:13&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;Motorcycle Enthusiasts&lt;/td&gt;
        &lt;td&gt;Readers of motorcycle news and reviews.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:13&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;Business News Readers&lt;/td&gt;
        &lt;td&gt;Readers of online business news content.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Thrift Store Shoppers&lt;/td&gt;
        &lt;td&gt;Consumers shopping online for clothing at thrift stores and researching locations.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-03-16 13:14:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;Advertising Professionals&lt;/td&gt;
        &lt;td&gt;People who read advertising industry news.&lt;/td&gt;
        &lt;td&gt;2016-05-26 14:57:59&lt;/td&gt;
        &lt;td&gt;2018-05-23 11:30:12&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students will have access to the same relevant schema SQL and example solutions which they can use with their Docker setup from within the course player!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
&lt;iframe src=&quot;https://embed.db-fiddle.com/51202689-29e3-4e8b-b585-41270b8f7103&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;The following questions can be considered key business questions that are required to be answered for the Fresh Segments team.&lt;/p&gt;

&lt;p&gt;Most questions can be answered using a single query however some questions are more open ended and require additional thought and not just a coded solution!&lt;/p&gt;

&lt;h3 id=&quot;data-exploration-and-cleansing&quot;&gt;Data Exploration and Cleansing&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Update the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_metrics&lt;/code&gt; table by modifying the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_year&lt;/code&gt; column to be a date data type with the start of the month&lt;/li&gt;
  &lt;li&gt;What is count of records in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_metrics&lt;/code&gt; for each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_year&lt;/code&gt; value sorted in chronological order (earliest to latest) with the null values appearing first?&lt;/li&gt;
  &lt;li&gt;What do you think we should do with these null values in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_metrics&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;How many &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id&lt;/code&gt; values exist in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_metrics&lt;/code&gt; table but not in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_map&lt;/code&gt; table? What about the other way around?&lt;/li&gt;
  &lt;li&gt;Summarise the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt; values in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_map&lt;/code&gt; by its total record count in this table&lt;/li&gt;
  &lt;li&gt;What sort of table join should we perform for our analysis and why? Check your logic by checking the rows where &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id = 21246&lt;/code&gt; in your joined output and include all columns from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_metrics&lt;/code&gt; and all columns from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_map&lt;/code&gt; except from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;id&lt;/code&gt; column.&lt;/li&gt;
  &lt;li&gt;Are there any records in your joined table where the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_year&lt;/code&gt; value is before the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;created_at&lt;/code&gt; value from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fresh_segments.interest_map&lt;/code&gt; table? Do you think these values are valid and why?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;interest-analysis&quot;&gt;Interest Analysis&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Which interests have been present in all &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_year&lt;/code&gt; dates in our dataset?&lt;/li&gt;
  &lt;li&gt;Using this same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;total_months&lt;/code&gt; measure - calculate the cumulative percentage of all records starting at 14 months - which &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;total_months&lt;/code&gt; value passes the 90% cumulative percentage value?&lt;/li&gt;
  &lt;li&gt;If we were to remove all &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest_id&lt;/code&gt; values which are lower than the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;total_months&lt;/code&gt; value we found in the previous question - how many total data points would we be removing?&lt;/li&gt;
  &lt;li&gt;Does this decision make sense to remove these data points from a business perspective? Use an example where there are all 14 months present to a removed &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;interest&lt;/code&gt; example for your arguments - think about what it means to have less months present from a segment perspective.&lt;/li&gt;
  &lt;li&gt;After removing these interests - how many unique interests are there for each month?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;segment-analysis&quot;&gt;Segment Analysis&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Using our filtered dataset by removing the interests with less than 6 months worth of data, which are the top 10 and bottom 10 interests which have the largest composition values in any &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_year&lt;/code&gt;? Only use the maximum composition value for each interest but you must keep the corresponding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_year&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Which 5 interests had the lowest average &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ranking&lt;/code&gt; value?&lt;/li&gt;
  &lt;li&gt;Which 5 interests had the largest standard deviation in their &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;percentile_ranking&lt;/code&gt; value?&lt;/li&gt;
  &lt;li&gt;For the 5 interests found in the previous question - what was minimum and maximum &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;percentile_ranking&lt;/code&gt; values for each interest and its corresponding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;year_month&lt;/code&gt; value? Can you describe what is happening for these 5 interests?&lt;/li&gt;
  &lt;li&gt;How would you describe our customers in this segment based off their composition and ranking values? What sort of products or services should we show to these customers and what should we avoid?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;index-analysis&quot;&gt;Index Analysis&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index_value&lt;/code&gt; is a measure which can be used to reverse calculate the average composition for Fresh Segments’ clients.&lt;/p&gt;

&lt;p&gt;Average composition can be calculated by dividing the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;composition&lt;/code&gt; column by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index_value&lt;/code&gt; column rounded to 2 decimal places.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;What is the top 10 interests by the average composition for each month?&lt;/li&gt;
  &lt;li&gt;For all of these top 10 interests - which interest appears the most often?&lt;/li&gt;
  &lt;li&gt;What is the average of the average composition for the top 10 interests for each month?&lt;/li&gt;
  &lt;li&gt;What is the 3 month rolling average of the max average composition value from September 2018 to August 2019 and include the previous top ranking interests in the same output shown below.&lt;/li&gt;
  &lt;li&gt;Provide a possible reason why the max average composition might change from month to month? Could it signal something is not quite right with the overall business model for Fresh Segments?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Required output for question 4:&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;month_year&lt;/th&gt;
        &lt;th&gt;interest_name&lt;/th&gt;
        &lt;th&gt;max_index_composition&lt;/th&gt;
        &lt;th&gt;3_month_moving_avg&lt;/th&gt;
        &lt;th&gt;1_month_ago&lt;/th&gt;
        &lt;th&gt;2_months_ago&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;2018-09-01&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers&lt;/td&gt;
        &lt;td&gt;8.26&lt;/td&gt;
        &lt;td&gt;7.61&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners: 7.21&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners: 7.36&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2018-10-01&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers&lt;/td&gt;
        &lt;td&gt;9.14&lt;/td&gt;
        &lt;td&gt;8.20&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 8.26&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners: 7.21&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2018-11-01&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers&lt;/td&gt;
        &lt;td&gt;8.28&lt;/td&gt;
        &lt;td&gt;8.56&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 9.14&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 8.26&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2018-12-01&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers&lt;/td&gt;
        &lt;td&gt;8.31&lt;/td&gt;
        &lt;td&gt;8.58&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 8.28&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 9.14&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-01-01&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers&lt;/td&gt;
        &lt;td&gt;7.66&lt;/td&gt;
        &lt;td&gt;8.08&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 8.31&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 8.28&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-02-01&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers&lt;/td&gt;
        &lt;td&gt;7.66&lt;/td&gt;
        &lt;td&gt;7.88&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 7.66&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 8.31&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-03-01&lt;/td&gt;
        &lt;td&gt;Alabama Trip Planners&lt;/td&gt;
        &lt;td&gt;6.54&lt;/td&gt;
        &lt;td&gt;7.29&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 7.66&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 7.66&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-04-01&lt;/td&gt;
        &lt;td&gt;Solar Energy Researchers&lt;/td&gt;
        &lt;td&gt;6.28&lt;/td&gt;
        &lt;td&gt;6.83&lt;/td&gt;
        &lt;td&gt;Alabama Trip Planners: 6.54&lt;/td&gt;
        &lt;td&gt;Work Comes First Travelers: 7.66&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-05-01&lt;/td&gt;
        &lt;td&gt;Readers of Honduran Content&lt;/td&gt;
        &lt;td&gt;4.41&lt;/td&gt;
        &lt;td&gt;5.74&lt;/td&gt;
        &lt;td&gt;Solar Energy Researchers: 6.28&lt;/td&gt;
        &lt;td&gt;Alabama Trip Planners: 6.54&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-06-01&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners&lt;/td&gt;
        &lt;td&gt;2.77&lt;/td&gt;
        &lt;td&gt;4.49&lt;/td&gt;
        &lt;td&gt;Readers of Honduran Content: 4.41&lt;/td&gt;
        &lt;td&gt;Solar Energy Researchers: 6.28&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-07-01&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners&lt;/td&gt;
        &lt;td&gt;2.82&lt;/td&gt;
        &lt;td&gt;3.33&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners: 2.77&lt;/td&gt;
        &lt;td&gt;Readers of Honduran Content: 4.41&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2019-08-01&lt;/td&gt;
        &lt;td&gt;Cosmetics and Beauty Shoppers&lt;/td&gt;
        &lt;td&gt;2.73&lt;/td&gt;
        &lt;td&gt;2.77&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners: 2.82&lt;/td&gt;
        &lt;td&gt;Las Vegas Trip Planners: 2.77&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;You have probably come across this concept of customer segments or marketing segments in your everyday life, maybe without you even noticing it!&lt;/p&gt;

&lt;p&gt;Segments or audiences are super popular in the digital marketing space and using these interests or traits of customers is a mainstay of massive businesses like Google, Facebook, Instagram, LinkedIn and other social media where there are targeted advertising.&lt;/p&gt;

&lt;p&gt;Traditional businesses such as this client for Fresh Segments usually upload their customer emails or matched cookies into various digital marketing systems in order to generate some sort of match, usually using some machine learning methods, to other similar customers with the same interests.&lt;/p&gt;

&lt;p&gt;Hopefully this case study helps you think about how these index metrics and compositions can be used for digital marketing!&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/8.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/8.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #7 - Balanced Tree Clothing Co.</title><link href="http://www.8weeksqlchallenge.com/case-study-7/" rel="alternate" type="text/html" title="Case Study #7 - Balanced Tree Clothing Co." /><published>2021-07-02T00:00:00+00:00</published><updated>2021-07-02T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-7</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-7/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/7.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Balanced Tree Clothing Company prides themselves on providing an optimised range of clothing and lifestyle wear for the modern adventurer!&lt;/p&gt;

&lt;p&gt;Danny, the CEO of this trendy fashion company has asked you to assist the team’s merchandising teams analyse their sales performance and generate a basic financial report to share with the wider business.&lt;/p&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;For this case study there is a total of 4 datasets for this case study - however you will only need to utilise 2 main tables to solve all of the regular questions, and the additional 2 tables are used only for the bonus challenge question!&lt;/p&gt;

&lt;h3 id=&quot;product-details&quot;&gt;Product Details&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;balanced_tree.product_details&lt;/code&gt; includes all information about the entire range that Balanced Clothing sells in their store.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;product_id&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
        &lt;th&gt;product_name&lt;/th&gt;
        &lt;th&gt;category_id&lt;/th&gt;
        &lt;th&gt;segment_id&lt;/th&gt;
        &lt;th&gt;style_id&lt;/th&gt;
        &lt;th&gt;category_name&lt;/th&gt;
        &lt;th&gt;segment_name&lt;/th&gt;
        &lt;th&gt;style_name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;c4a632&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;Navy Oversized Jeans - Womens&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Jeans&lt;/td&gt;
        &lt;td&gt;Navy Oversized&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;e83aa3&lt;/td&gt;
        &lt;td&gt;32&lt;/td&gt;
        &lt;td&gt;Black Straight Jeans - Womens&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Jeans&lt;/td&gt;
        &lt;td&gt;Black Straight&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;e31d39&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Cream Relaxed Jeans - Womens&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Jeans&lt;/td&gt;
        &lt;td&gt;Cream Relaxed&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;d5e9a6&lt;/td&gt;
        &lt;td&gt;23&lt;/td&gt;
        &lt;td&gt;Khaki Suit Jacket - Womens&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Jacket&lt;/td&gt;
        &lt;td&gt;Khaki Suit&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;72f5d4&lt;/td&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;Indigo Rain Jacket - Womens&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Jacket&lt;/td&gt;
        &lt;td&gt;Indigo Rain&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9ec847&lt;/td&gt;
        &lt;td&gt;54&lt;/td&gt;
        &lt;td&gt;Grey Fashion Jacket - Womens&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Jacket&lt;/td&gt;
        &lt;td&gt;Grey Fashion&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5d267b&lt;/td&gt;
        &lt;td&gt;40&lt;/td&gt;
        &lt;td&gt;White Tee Shirt - Mens&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Shirt&lt;/td&gt;
        &lt;td&gt;White Tee&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;c8d436&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Teal Button Up Shirt - Mens&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;14&lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Shirt&lt;/td&gt;
        &lt;td&gt;Teal Button Up&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2a2353&lt;/td&gt;
        &lt;td&gt;57&lt;/td&gt;
        &lt;td&gt;Blue Polo Shirt - Mens&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Shirt&lt;/td&gt;
        &lt;td&gt;Blue Polo&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;f084eb&lt;/td&gt;
        &lt;td&gt;36&lt;/td&gt;
        &lt;td&gt;Navy Solid Socks - Mens&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Socks&lt;/td&gt;
        &lt;td&gt;Navy Solid&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;b9a74d&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;White Striped Socks - Mens&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Socks&lt;/td&gt;
        &lt;td&gt;White Striped&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2feb6b&lt;/td&gt;
        &lt;td&gt;29&lt;/td&gt;
        &lt;td&gt;Pink Fluro Polkadot Socks - Mens&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Socks&lt;/td&gt;
        &lt;td&gt;Pink Fluro Polkadot&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;product-sales&quot;&gt;Product Sales&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;balanced_tree.sales&lt;/code&gt; contains product level information for all the transactions made for Balanced Tree including quantity, price, percentage discount, member status, a transaction ID and also the transaction timestamp.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;prod_id&lt;/th&gt;
        &lt;th&gt;qty&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
        &lt;th&gt;discount&lt;/th&gt;
        &lt;th&gt;member&lt;/th&gt;
        &lt;th&gt;txn_id&lt;/th&gt;
        &lt;th&gt;start_txn_time&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;c4a632&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;54f307&lt;/td&gt;
        &lt;td&gt;2021-02-13 01:59:43.296&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5d267b&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;40&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;54f307&lt;/td&gt;
        &lt;td&gt;2021-02-13 01:59:43.296&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;b9a74d&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;54f307&lt;/td&gt;
        &lt;td&gt;2021-02-13 01:59:43.296&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2feb6b&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;29&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;54f307&lt;/td&gt;
        &lt;td&gt;2021-02-13 01:59:43.296&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;c4a632&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;21&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;26cc98&lt;/td&gt;
        &lt;td&gt;2021-01-19 01:39:00.3456&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;e31d39&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;21&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;26cc98&lt;/td&gt;
        &lt;td&gt;2021-01-19 01:39:00.3456&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;72f5d4&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;21&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;26cc98&lt;/td&gt;
        &lt;td&gt;2021-01-19 01:39:00.3456&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2a2353&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;57&lt;/td&gt;
        &lt;td&gt;21&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;26cc98&lt;/td&gt;
        &lt;td&gt;2021-01-19 01:39:00.3456&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;f084eb&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;36&lt;/td&gt;
        &lt;td&gt;21&lt;/td&gt;
        &lt;td&gt;t&lt;/td&gt;
        &lt;td&gt;26cc98&lt;/td&gt;
        &lt;td&gt;2021-01-19 01:39:00.3456&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;c4a632&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;21&lt;/td&gt;
        &lt;td&gt;f&lt;/td&gt;
        &lt;td&gt;ef648d&lt;/td&gt;
        &lt;td&gt;2021-01-27 02:18:17.1648&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;product-hierarcy--product-price&quot;&gt;Product Hierarcy &amp;amp; Product Price&lt;/h3&gt;

&lt;p&gt;Thes tables are used only for the bonus question where we will use them to recreate the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;balanced_tree.product_details&lt;/code&gt; table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;balanced_tree.product_hierarchy&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;id&lt;/th&gt;
        &lt;th&gt;parent_id&lt;/th&gt;
        &lt;th&gt;level_text&lt;/th&gt;
        &lt;th&gt;level_name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;Womens&lt;/td&gt;
        &lt;td&gt;Category&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;Mens&lt;/td&gt;
        &lt;td&gt;Category&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Jeans&lt;/td&gt;
        &lt;td&gt;Segment&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Jacket&lt;/td&gt;
        &lt;td&gt;Segment&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;Shirt&lt;/td&gt;
        &lt;td&gt;Segment&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;Socks&lt;/td&gt;
        &lt;td&gt;Segment&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Navy Oversized&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Black Straight&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Cream Relaxed&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Khaki Suit&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Indigo Rain&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Grey Fashion&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;White Tee&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;14&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Teal Button Up&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Blue Polo&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;Navy Solid&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;White Striped&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;Pink Fluro Polkadot&lt;/td&gt;
        &lt;td&gt;Style&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;balanced_tree.product_prices&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;id&lt;/th&gt;
        &lt;th&gt;product_id&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;c4a632&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;e83aa3&lt;/td&gt;
        &lt;td&gt;32&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;e31d39&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;d5e9a6&lt;/td&gt;
        &lt;td&gt;23&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;72f5d4&lt;/td&gt;
        &lt;td&gt;19&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;9ec847&lt;/td&gt;
        &lt;td&gt;54&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;5d267b&lt;/td&gt;
        &lt;td&gt;40&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;14&lt;/td&gt;
        &lt;td&gt;c8d436&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;2a2353&lt;/td&gt;
        &lt;td&gt;57&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;f084eb&lt;/td&gt;
        &lt;td&gt;36&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;17&lt;/td&gt;
        &lt;td&gt;b9a74d&lt;/td&gt;
        &lt;td&gt;17&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2feb6b&lt;/td&gt;
        &lt;td&gt;29&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students will have access to the same relevant schema SQL and example solutions which they can use with their Docker setup from within the course player!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
&lt;iframe src=&quot;https://embed.db-fiddle.com/b7ab2fdd-a8da-4ce1-b43d-40f253732245&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;The following questions can be considered key business questions and metrics that the Balanced Tree team requires for their monthly reports.&lt;/p&gt;

&lt;p&gt;Each question can be answered using a single query - but as you are writing the SQL to solve each individual problem, keep in mind how you would generate all of these metrics in a single SQL script which the Balanced Tree team can run each month.&lt;/p&gt;

&lt;h3 id=&quot;high-level-sales-analysis&quot;&gt;High Level Sales Analysis&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;What was the total quantity sold for all products?&lt;/li&gt;
  &lt;li&gt;What is the total generated revenue for all products before discounts?&lt;/li&gt;
  &lt;li&gt;What was the total discount amount for all products?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;transaction-analysis&quot;&gt;Transaction Analysis&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;How many unique transactions were there?&lt;/li&gt;
  &lt;li&gt;What is the average unique products purchased in each transaction?&lt;/li&gt;
  &lt;li&gt;What are the 25th, 50th and 75th percentile values for the revenue per transaction?&lt;/li&gt;
  &lt;li&gt;What is the average discount value per transaction?&lt;/li&gt;
  &lt;li&gt;What is the percentage split of all transactions for members vs non-members?&lt;/li&gt;
  &lt;li&gt;What is the average revenue for member transactions and non-member transactions?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;product-analysis&quot;&gt;Product Analysis&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;What are the top 3 products by total revenue before discount?&lt;/li&gt;
  &lt;li&gt;What is the total quantity, revenue and discount for each segment?&lt;/li&gt;
  &lt;li&gt;What is the top selling product for each segment?&lt;/li&gt;
  &lt;li&gt;What is the total quantity, revenue and discount for each category?&lt;/li&gt;
  &lt;li&gt;What is the top selling product for each category?&lt;/li&gt;
  &lt;li&gt;What is the percentage split of revenue by product for each segment?&lt;/li&gt;
  &lt;li&gt;What is the percentage split of revenue by segment for each category?&lt;/li&gt;
  &lt;li&gt;What is the percentage split of total revenue by category?&lt;/li&gt;
  &lt;li&gt;What is the total transaction “penetration” for each product? (hint: penetration = number of transactions where at least 1 quantity of a product was purchased divided by total number of transactions)&lt;/li&gt;
  &lt;li&gt;What is the most common combination of at least 1 quantity of any 3 products in a 1 single transaction?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;reporting-challenge&quot;&gt;Reporting Challenge&lt;/h3&gt;

&lt;p&gt;Write a single SQL script that combines all of the previous questions into a scheduled report that the Balanced Tree team can run at the beginning of each month to calculate the previous month’s values.&lt;/p&gt;

&lt;p&gt;Imagine that the Chief Financial Officer (which is also Danny) has asked for all of these questions at the end of every month.&lt;/p&gt;

&lt;p&gt;He first wants you to generate the data for January only - but then he also wants you to demonstrate that you can easily run the samne analysis for February without many changes (if at all).&lt;/p&gt;

&lt;p&gt;Feel free to split up your final outputs into as many tables as you need - but be sure to explicitly reference which table outputs relate to which question for full marks :)&lt;/p&gt;

&lt;h3 id=&quot;bonus-challenge&quot;&gt;Bonus Challenge&lt;/h3&gt;

&lt;p&gt;Use a single SQL query to transform the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_hierarchy&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_prices&lt;/code&gt; datasets to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_details&lt;/code&gt; table.&lt;/p&gt;

&lt;p&gt;Hint: you may want to consider using a recursive CTE to solve this problem!&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Sales, transactions and product exposure is always going to be a main objective for many data analysts and data scientists when working within a company that sells some type of product - Spoiler alert: nearly all companies will sell products!&lt;/p&gt;

&lt;p&gt;Being able to navigate your way around a product hierarchy and understand the different levels of the structures as well as being able to join these details to sales related datasets will be super valuable for anyone wanting to work within a financial, customer or exploratory analytics capacity.&lt;/p&gt;

&lt;p&gt;Hopefully these questions helped provide some exposure to the type of analysis we perform daily in these sorts of roles!&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #8!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-8&quot;&gt;&lt;img src=&quot;/images/case-study-designs/8.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/7.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/7.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #6 - Clique Bait</title><link href="http://www.8weeksqlchallenge.com/case-study-6/" rel="alternate" type="text/html" title="Case Study #6 - Clique Bait" /><published>2021-06-29T00:00:00+00:00</published><updated>2021-06-29T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-6</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-6/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/6.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Clique Bait is not like your regular online seafood store - the founder and CEO Danny, was also a part of a digital data analytics team and wanted to expand his knowledge into the seafood industry!&lt;/p&gt;

&lt;p&gt;In this case study - you are required to support Danny’s vision and analyse his dataset and come up with creative solutions to calculate funnel fallout rates for the Clique Bait online store.&lt;/p&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;For this case study there is a total of 5 datasets which you will need to combine to solve all of the questions.&lt;/p&gt;

&lt;h3 id=&quot;users&quot;&gt;Users&lt;/h3&gt;

&lt;p&gt;Customers who visit the Clique Bait website are tagged via their &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cookie_id&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;user_id&lt;/th&gt;
        &lt;th&gt;cookie_id&lt;/th&gt;
        &lt;th&gt;start_date&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;397&lt;/td&gt;
        &lt;td&gt;3759ff&lt;/td&gt;
        &lt;td&gt;2020-03-30 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;215&lt;/td&gt;
        &lt;td&gt;863329&lt;/td&gt;
        &lt;td&gt;2020-01-26 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;191&lt;/td&gt;
        &lt;td&gt;eefca9&lt;/td&gt;
        &lt;td&gt;2020-03-15 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;89&lt;/td&gt;
        &lt;td&gt;764796&lt;/td&gt;
        &lt;td&gt;2020-01-07 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;127&lt;/td&gt;
        &lt;td&gt;17ccc5&lt;/td&gt;
        &lt;td&gt;2020-01-22 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;81&lt;/td&gt;
        &lt;td&gt;b0b666&lt;/td&gt;
        &lt;td&gt;2020-03-01 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;260&lt;/td&gt;
        &lt;td&gt;a4f236&lt;/td&gt;
        &lt;td&gt;2020-01-08 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;203&lt;/td&gt;
        &lt;td&gt;d1182f&lt;/td&gt;
        &lt;td&gt;2020-04-18 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;23&lt;/td&gt;
        &lt;td&gt;12dbc8&lt;/td&gt;
        &lt;td&gt;2020-01-18 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;375&lt;/td&gt;
        &lt;td&gt;f61d69&lt;/td&gt;
        &lt;td&gt;2020-01-03 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;
&lt;h3 id=&quot;events&quot;&gt;Events&lt;/h3&gt;

&lt;p&gt;Customer visits are logged in this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;events&lt;/code&gt; table at a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cookie_id&lt;/code&gt; level and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;event_type&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;page_id&lt;/code&gt; values can be used to join onto relevant satellite tables to obtain further information about each event.&lt;/p&gt;

&lt;p&gt;The sequence_number is used to order the events within each visit.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;visit_id&lt;/th&gt;
        &lt;th&gt;cookie_id&lt;/th&gt;
        &lt;th&gt;page_id&lt;/th&gt;
        &lt;th&gt;event_type&lt;/th&gt;
        &lt;th&gt;sequence_number&lt;/th&gt;
        &lt;th&gt;event_time&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;719fd3&lt;/td&gt;
        &lt;td&gt;3d83d3&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-03-02 00:29:09.975502&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;fb1eb1&lt;/td&gt;
        &lt;td&gt;c5ff25&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;2020-01-22 07:59:16.761931&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;23fe81&lt;/td&gt;
        &lt;td&gt;1e8c2d&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;2020-03-21 13:14:11.745667&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;ad91aa&lt;/td&gt;
        &lt;td&gt;648115&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2020-04-27 16:28:09.824606&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5576d7&lt;/td&gt;
        &lt;td&gt;ac418c&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-01-18 04:55:10.149236&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;48308b&lt;/td&gt;
        &lt;td&gt;c686c1&lt;/td&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2020-01-29 06:10:38.702163&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;46b17d&lt;/td&gt;
        &lt;td&gt;78f9b3&lt;/td&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;2020-02-16 09:45:31.926407&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9fd196&lt;/td&gt;
        &lt;td&gt;ccf057&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2020-02-14 08:29:12.922164&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;edf853&lt;/td&gt;
        &lt;td&gt;f85454&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2020-02-22 12:59:07.652207&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3c6716&lt;/td&gt;
        &lt;td&gt;02e74f&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2020-01-31 17:56:20.777383&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;event-identifier&quot;&gt;Event Identifier&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;event_identifier&lt;/code&gt; table shows the types of events which are captured by Clique Bait’s digital data systems.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;event_type&lt;/th&gt;
        &lt;th&gt;event_name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Page View&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;Add to Cart&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Purchase&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Ad Impression&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Ad Click&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;campaign-identifier&quot;&gt;Campaign Identifier&lt;/h3&gt;

&lt;p&gt;This table shows information for the 3 campaigns that Clique Bait has ran on their website so far in 2020.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;campaign_id&lt;/th&gt;
        &lt;th&gt;products&lt;/th&gt;
        &lt;th&gt;campaign_name&lt;/th&gt;
        &lt;th&gt;start_date&lt;/th&gt;
        &lt;th&gt;end_date&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1-3&lt;/td&gt;
        &lt;td&gt;BOGOF - Fishing For Compliments&lt;/td&gt;
        &lt;td&gt;2020-01-01 00:00:00&lt;/td&gt;
        &lt;td&gt;2020-01-14 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;4-5&lt;/td&gt;
        &lt;td&gt;25% Off - Living The Lux Life&lt;/td&gt;
        &lt;td&gt;2020-01-15 00:00:00&lt;/td&gt;
        &lt;td&gt;2020-01-28 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;6-8&lt;/td&gt;
        &lt;td&gt;Half Off - Treat Your Shellf(ish)&lt;/td&gt;
        &lt;td&gt;2020-02-01 00:00:00&lt;/td&gt;
        &lt;td&gt;2020-03-31 00:00:00&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;page-hierarchy&quot;&gt;Page Hierarchy&lt;/h3&gt;

&lt;p&gt;This table lists all of the pages on the Clique Bait website which are tagged and have data passing through from user interaction events.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;page_id&lt;/th&gt;
        &lt;th&gt;page_name&lt;/th&gt;
        &lt;th&gt;product_category&lt;/th&gt;
        &lt;th&gt;product_id&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Home Page&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;All Products&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Salmon&lt;/td&gt;
        &lt;td&gt;Fish&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Kingfish&lt;/td&gt;
        &lt;td&gt;Fish&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Tuna&lt;/td&gt;
        &lt;td&gt;Fish&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;Russian Caviar&lt;/td&gt;
        &lt;td&gt;Luxury&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;Black Truffle&lt;/td&gt;
        &lt;td&gt;Luxury&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;Abalone&lt;/td&gt;
        &lt;td&gt;Shellfish&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;Lobster&lt;/td&gt;
        &lt;td&gt;Shellfish&lt;/td&gt;
        &lt;td&gt;7&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Crab&lt;/td&gt;
        &lt;td&gt;Shellfish&lt;/td&gt;
        &lt;td&gt;8&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;Oyster&lt;/td&gt;
        &lt;td&gt;Shellfish&lt;/td&gt;
        &lt;td&gt;9&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Checkout&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;Confirmation&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the provided DB Fiddle instance to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;&lt;button type=&quot;button&quot;&gt;&lt;a href=&quot;https://www.db-fiddle.com/f/jmnwogTsUE8hGqkZv9H7E8/17&quot; target=&quot;_blank&quot;&gt;Click here&lt;/a&gt;&lt;/button&gt; to open a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;In past case studies - you would have seen an embedded DB Fiddle instance, but this time it seems like this week’s case study datasets might have been too big and broke the API for the embedded iframe code - whoops!!!&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students will have access to the same relevant schema SQL and example solutions which they can use with their Docker setup from within the course player!&lt;/p&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;h3 id=&quot;1-enterprise-relationship-diagram&quot;&gt;1. Enterprise Relationship Diagram&lt;/h3&gt;

&lt;p&gt;Using the following DDL schema details to create an ERD for all the Clique Bait datasets.&lt;/p&gt;

&lt;p&gt;&lt;button type=&quot;button&quot;&gt;&lt;a href=&quot;https://dbdiagram.io/&quot; target=&quot;_blank&quot;&gt;Click here&lt;/a&gt;&lt;/button&gt; to access the DB Diagram tool to create the ERD.&lt;/p&gt;

&lt;div class=&quot;language-sql highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clique_bait&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;event_identifier&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;event_type&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;event_name&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clique_bait&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;campaign_identifier&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;campaign_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;products&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;campaign_name&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;start_date&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;TIMESTAMP&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;end_date&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;TIMESTAMP&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clique_bait&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;page_hierarchy&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;page_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;page_name&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;product_category&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;product_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clique_bait&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;users&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;user_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;cookie_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;start_date&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;TIMESTAMP&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;TABLE&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clique_bait&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;events&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;visit_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;cookie_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;VARCHAR&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;page_id&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;event_type&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;sequence_number&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;INTEGER&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;nv&quot;&gt;&quot;event_time&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;TIMESTAMP&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;2-digital-analysis&quot;&gt;2. Digital Analysis&lt;/h3&gt;

&lt;p&gt;Using the available datasets - answer the following questions using a single query for each one:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;How many users are there?&lt;/li&gt;
  &lt;li&gt;How many cookies does each user have on average?&lt;/li&gt;
  &lt;li&gt;What is the unique number of visits by all users per month?&lt;/li&gt;
  &lt;li&gt;What is the number of events for each event type?&lt;/li&gt;
  &lt;li&gt;What is the percentage of visits which have a purchase event?&lt;/li&gt;
  &lt;li&gt;What is the percentage of visits which view the checkout page but do not have a purchase event?&lt;/li&gt;
  &lt;li&gt;What are the top 3 pages by number of views?&lt;/li&gt;
  &lt;li&gt;What is the number of views and cart adds for each product category?&lt;/li&gt;
  &lt;li&gt;What are the top 3 products by purchases?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;3-product-funnel-analysis&quot;&gt;3. Product Funnel Analysis&lt;/h3&gt;

&lt;p&gt;Using a single SQL query - create a new output table which has the following details:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;How many times was each product viewed?&lt;/li&gt;
  &lt;li&gt;How many times was each product added to cart?&lt;/li&gt;
  &lt;li&gt;How many times was each product added to a cart but not purchased (abandoned)?&lt;/li&gt;
  &lt;li&gt;How many times was each product purchased?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Additionally, create another table which further aggregates the data for the above points but this time for each product category instead of individual products.&lt;/p&gt;

&lt;p&gt;Use your 2 new output tables - answer the following questions:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Which product had the most views, cart adds and purchases?&lt;/li&gt;
  &lt;li&gt;Which product was most likely to be abandoned?&lt;/li&gt;
  &lt;li&gt;Which product had the highest view to purchase percentage?&lt;/li&gt;
  &lt;li&gt;What is the average conversion rate from view to cart add?&lt;/li&gt;
  &lt;li&gt;What is the average conversion rate from cart add to purchase?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;3-campaigns-analysis&quot;&gt;3. Campaigns Analysis&lt;/h3&gt;

&lt;p&gt;Generate a table that has 1 single row for every unique &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visit_id&lt;/code&gt; record and has the following columns:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user_id&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visit_id&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visit_start_time&lt;/code&gt;: the earliest &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;event_time&lt;/code&gt; for each visit&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;page_views&lt;/code&gt;: count of page views for each visit&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cart_adds&lt;/code&gt;: count of product cart add events for each visit&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;purchase&lt;/code&gt;: 1/0 flag if a purchase event exists for each visit&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;campaign_name&lt;/code&gt;: map the visit to a campaign if the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;visit_start_time&lt;/code&gt; falls between the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_date&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;end_date&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;impression&lt;/code&gt;: count of ad impressions for each visit&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;click&lt;/code&gt;: count of ad clicks for each visit&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;(Optional column)&lt;/strong&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cart_products&lt;/code&gt;: a comma separated text value with products added to the cart sorted by the order they were added to the cart (hint: use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sequence_number&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the subsequent dataset to generate at least 5 insights for the Clique Bait team - bonus: prepare a single A4 infographic that the team can use for their management reporting sessions, be sure to emphasise the most important points from your findings.&lt;/p&gt;

&lt;p&gt;Some ideas you might want to investigate further include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Identifying users who have received impressions during each campaign period and comparing each metric with other users who did not have an impression event&lt;/li&gt;
  &lt;li&gt;Does clicking on an impression lead to higher purchase rates?&lt;/li&gt;
  &lt;li&gt;What is the uplift in purchase rate when comparing users who click on a campaign impression versus users who do not receive an impression? What if we compare them with users who just an impression but do not click?&lt;/li&gt;
  &lt;li&gt;What metrics can you use to quantify the success or failure of each campaign compared to eachother?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This case study is based off my many years working with Digital datasets in consumer banking and retail supermarkets - all of the datasets are designed based off real datasets I’ve come across in challenging problem solving scenarios and the questions reflect similar problems which I worked on.&lt;/p&gt;

&lt;p&gt;Campaign analysis is almost everywhere in the data world, especially in marketing, digital, UX and retail industries - and being able to analyse views, clicks and other digital behaviour is a critical skill to have in your toolbelt as a data professional!&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #7!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-7&quot;&gt;&lt;img src=&quot;/images/case-study-designs/7.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/6.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/6.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #5 - Data Mart</title><link href="http://www.8weeksqlchallenge.com/case-study-5/" rel="alternate" type="text/html" title="Case Study #5 - Data Mart" /><published>2021-06-20T00:00:00+00:00</published><updated>2021-06-20T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-5</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-5/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/5.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Data Mart is Danny’s latest venture and after running international operations for his online supermarket that specialises in fresh produce - Danny is asking for your support to analyse his sales performance.&lt;/p&gt;

&lt;p&gt;In June 2020 - large scale supply changes were made at Data Mart. All Data Mart products now use sustainable packaging methods in every single step from the farm all the way to the customer.&lt;/p&gt;

&lt;p&gt;Danny needs your help to quantify the impact of this change on the sales performance for Data Mart and it’s separate business areas.&lt;/p&gt;

&lt;p&gt;The key business question he wants you to help him answer are the following:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What was the quantifiable impact of the changes introduced in June 2020?&lt;/li&gt;
  &lt;li&gt;Which platform, region, segment and customer types were the most impacted by this change?&lt;/li&gt;
  &lt;li&gt;What can we do about future introduction of similar sustainability updates to the business to minimise impact on sales?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;For this case study there is only a single table: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_mart.weekly_sales&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Entity Relationship Diagram&lt;/code&gt; is shown below with the data types made clear, please note that there is only this one table - hence why it looks a little bit lonely!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/case-study-5-erd.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;column-dictionary&quot;&gt;Column Dictionary&lt;/h3&gt;

&lt;p&gt;The columns are pretty self-explanatory based on the column names but here are some further details about the dataset:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Data Mart has international operations using a multi-&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;region&lt;/code&gt; strategy&lt;/li&gt;
  &lt;li&gt;Data Mart has both, a retail and online &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;platform&lt;/code&gt; in the form of a Shopify store front to serve their customers&lt;/li&gt;
  &lt;li&gt;Customer &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;segment&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_type&lt;/code&gt; data relates to personal age and demographics information that is shared with Data Mart&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;transactions&lt;/code&gt; is the count of unique purchases made through Data Mart and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sales&lt;/code&gt; is the actual dollar amount of purchases&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each record in the dataset is related to a specific aggregated slice of the underlying sales data rolled up into a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; value which represents the start of the sales week.&lt;/p&gt;

&lt;h3 id=&quot;example-rows&quot;&gt;Example Rows&lt;/h3&gt;

&lt;p&gt;10 random rows are shown in the table output below from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_mart.weekly_sales&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;week_date&lt;/th&gt;
        &lt;th&gt;region&lt;/th&gt;
        &lt;th&gt;platform&lt;/th&gt;
        &lt;th&gt;segment&lt;/th&gt;
        &lt;th&gt;customer_type&lt;/th&gt;
        &lt;th&gt;transactions&lt;/th&gt;
        &lt;th&gt;sales&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;9/9/20&lt;/td&gt;
        &lt;td&gt;OCEANIA&lt;/td&gt;
        &lt;td&gt;Shopify&lt;/td&gt;
        &lt;td&gt;C3&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;610&lt;/td&gt;
        &lt;td&gt;110033.89&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;29/7/20&lt;/td&gt;
        &lt;td&gt;AFRICA&lt;/td&gt;
        &lt;td&gt;Retail&lt;/td&gt;
        &lt;td&gt;C1&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;110692&lt;/td&gt;
        &lt;td&gt;3053771.19&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;22/7/20&lt;/td&gt;
        &lt;td&gt;EUROPE&lt;/td&gt;
        &lt;td&gt;Shopify&lt;/td&gt;
        &lt;td&gt;C4&lt;/td&gt;
        &lt;td&gt;Existing&lt;/td&gt;
        &lt;td&gt;24&lt;/td&gt;
        &lt;td&gt;8101.54&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13/5/20&lt;/td&gt;
        &lt;td&gt;AFRICA&lt;/td&gt;
        &lt;td&gt;Shopify&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;Guest&lt;/td&gt;
        &lt;td&gt;5287&lt;/td&gt;
        &lt;td&gt;1003301.37&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;24/7/19&lt;/td&gt;
        &lt;td&gt;ASIA&lt;/td&gt;
        &lt;td&gt;Retail&lt;/td&gt;
        &lt;td&gt;C1&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;127342&lt;/td&gt;
        &lt;td&gt;3151780.41&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10/7/19&lt;/td&gt;
        &lt;td&gt;CANADA&lt;/td&gt;
        &lt;td&gt;Shopify&lt;/td&gt;
        &lt;td&gt;F3&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;51&lt;/td&gt;
        &lt;td&gt;8844.93&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;26/6/19&lt;/td&gt;
        &lt;td&gt;OCEANIA&lt;/td&gt;
        &lt;td&gt;Retail&lt;/td&gt;
        &lt;td&gt;C3&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;152921&lt;/td&gt;
        &lt;td&gt;5551385.36&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;29/5/19&lt;/td&gt;
        &lt;td&gt;SOUTH AMERICA&lt;/td&gt;
        &lt;td&gt;Shopify&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;53&lt;/td&gt;
        &lt;td&gt;10056.2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;22/8/18&lt;/td&gt;
        &lt;td&gt;AFRICA&lt;/td&gt;
        &lt;td&gt;Retail&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;Existing&lt;/td&gt;
        &lt;td&gt;31721&lt;/td&gt;
        &lt;td&gt;1718863.58&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;25/7/18&lt;/td&gt;
        &lt;td&gt;SOUTH AMERICA&lt;/td&gt;
        &lt;td&gt;Retail&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;New&lt;/td&gt;
        &lt;td&gt;2136&lt;/td&gt;
        &lt;td&gt;81757.91&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students will have access to the same relevant schema SQL and example solutions which they can use with their Docker setup from within the course player!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
&lt;iframe src=&quot;https://embed.db-fiddle.com/3368f44b-e644-4e9b-9bf2-fc5adf2a3b45&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;The following case study questions require some data cleaning steps before we start to unpack Danny’s key business questions in more depth.&lt;/p&gt;

&lt;h3 id=&quot;1-data-cleansing-steps&quot;&gt;1. Data Cleansing Steps&lt;/h3&gt;

&lt;p&gt;In a single query, perform the following operations and generate a new table in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_mart&lt;/code&gt; schema named &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clean_weekly_sales&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Convert the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; to a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DATE&lt;/code&gt; format&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_number&lt;/code&gt; as the second column for each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; value, for example any value from the 1st of January to 7th of January will be 1, 8th to 14th will be 2 etc&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;month_number&lt;/code&gt; with the calendar month for each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; value as the 3rd column&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;calendar_year&lt;/code&gt; column as the 4th column containing either 2018, 2019 or 2020 values&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Add a new column called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;age_band&lt;/code&gt; after the original &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;segment&lt;/code&gt; column using the following mapping on the number inside the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;segment&lt;/code&gt; value&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;segment&lt;/th&gt;
      &lt;th&gt;age_band&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;Young Adults&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;Middle Aged&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3 or 4&lt;/td&gt;
      &lt;td&gt;Retirees&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;ul&gt;
  &lt;li&gt;Add a new &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;demographic&lt;/code&gt; column using the following mapping for the first letter in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;segment&lt;/code&gt; values:&lt;/li&gt;
&lt;/ul&gt;

&lt;table&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;segment&lt;/td&gt;
      &lt;td&gt;demographic&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;C&lt;/td&gt;
      &lt;td&gt;Couples&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;F&lt;/td&gt;
      &lt;td&gt;Families&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Ensure all &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; string values with an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;unknown&quot;&lt;/code&gt; string value in the original &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;segment&lt;/code&gt; column as well as the new &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;age_band&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;demographic&lt;/code&gt; columns&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Generate a new &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;avg_transaction&lt;/code&gt; column as the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sales&lt;/code&gt; value divided by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;transactions&lt;/code&gt; rounded to 2 decimal places for each record&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;2-data-exploration&quot;&gt;2. Data Exploration&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;What day of the week is used for each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; value?&lt;/li&gt;
  &lt;li&gt;What range of week numbers are missing from the dataset?&lt;/li&gt;
  &lt;li&gt;How many total transactions were there for each year in the dataset?&lt;/li&gt;
  &lt;li&gt;What is the total sales for each region for each month?&lt;/li&gt;
  &lt;li&gt;What is the total count of transactions for each platform&lt;/li&gt;
  &lt;li&gt;What is the percentage of sales for Retail vs Shopify for each month?&lt;/li&gt;
  &lt;li&gt;What is the percentage of sales by demographic for each year in the dataset?&lt;/li&gt;
  &lt;li&gt;Which &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;age_band&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;demographic&lt;/code&gt; values contribute the most to Retail sales?&lt;/li&gt;
  &lt;li&gt;Can we use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;avg_transaction&lt;/code&gt; column to find the average transaction size for each year for Retail vs Shopify? If not - how would you calculate it instead?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;3-before--after-analysis&quot;&gt;3. Before &amp;amp; After Analysis&lt;/h3&gt;

&lt;p&gt;This technique is usually used when we inspect an important event and want to inspect the impact before and after a certain point in time.&lt;/p&gt;

&lt;p&gt;Taking the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; value of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2020-06-15&lt;/code&gt; as the baseline week where the Data Mart sustainable packaging changes came into effect.&lt;/p&gt;

&lt;p&gt;We would include all &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; values for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2020-06-15&lt;/code&gt; as the start of the period &lt;strong&gt;after&lt;/strong&gt; the change and the previous &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;week_date&lt;/code&gt; values would be &lt;strong&gt;before&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using this analysis approach - answer the following questions:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;What is the total sales for the 4 weeks before and after &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2020-06-15&lt;/code&gt;? What is the growth or reduction rate in actual values and percentage of sales?&lt;/li&gt;
  &lt;li&gt;What about the entire 12 weeks before and after?&lt;/li&gt;
  &lt;li&gt;How do the sale metrics for these 2 periods before and after compare with the previous years in 2018 and 2019?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;4-bonus-question&quot;&gt;4. Bonus Question&lt;/h3&gt;

&lt;p&gt;Which areas of the business have the highest negative impact in sales metrics performance in 2020 for the 12 week before and after period?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;region&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;platform&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;age_band&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;demographic&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_type&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do you have any further recommendations for Danny’s team at Data Mart or any interesting insights based off this analysis?&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This case study actually is based off a real life change in Australia retailers where plastic bags were no longer provided for free - as you can expect, some customers would have changed their shopping behaviour because of this change!&lt;/p&gt;

&lt;p&gt;Analysis which is related to certain key events which can have a significant impact on sales or engagement metrics is always a part of the data analytics menu. Learning how to approach these types of problems is a super valuable lesson and hopefully these ideas can help you next time you’re faced with a tough problem like this in the workplace!&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #6!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-6&quot;&gt;&lt;img src=&quot;/images/case-study-designs/6.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/5.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/5.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #4 - Data Bank</title><link href="http://www.8weeksqlchallenge.com/case-study-4/" rel="alternate" type="text/html" title="Case Study #4 - Data Bank" /><published>2021-06-01T00:00:00+00:00</published><updated>2021-06-01T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-4</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-4/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/4.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;There is a new innovation in the financial industry called Neo-Banks: new aged digital only banks without physical branches.&lt;/p&gt;

&lt;p&gt;Danny thought that there should be some sort of intersection between these new age banks, cryptocurrency and the data world…so he decides to launch a new initiative - Data Bank!&lt;/p&gt;

&lt;p&gt;Data Bank runs just like any other digital bank - but it isn’t only for banking activities, they also have the world’s most secure distributed data storage platform!&lt;/p&gt;

&lt;p&gt;Customers are allocated cloud data storage limits which are directly linked to how much money they have in their accounts. There are a few interesting caveats that go with this business model, and this is where the Data Bank team need your help!&lt;/p&gt;

&lt;p&gt;The management team at Data Bank want to increase their total customer base - but also need some help tracking just how much data storage their customers will need.&lt;/p&gt;

&lt;p&gt;This case study is all about calculating metrics, growth and helping the business analyse their data in a smart way to better forecast and plan for their future developments!&lt;/p&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;The Data Bank team have prepared a data model for this case study as well as a few example rows from the complete dataset below to get you familiar with their tables.&lt;/p&gt;

&lt;h3 id=&quot;entity-relationship-diagram&quot;&gt;Entity Relationship Diagram&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/images/case-study-4-erd.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;table-1-regions&quot;&gt;Table 1: Regions&lt;/h3&gt;

&lt;p&gt;Just like popular cryptocurrency platforms - Data Bank is also run off a network of nodes where both money and data is stored across the globe. In a traditional banking sense - you can think of these nodes as bank branches or stores that exist around the world.&lt;/p&gt;

&lt;p&gt;This &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;regions&lt;/code&gt; table contains the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;region_id&lt;/code&gt; and their respective &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;region_name&lt;/code&gt; values&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;region_id&lt;/th&gt;
        &lt;th&gt;region_name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Africa&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;America&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Asia&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Europe&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Oceania&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-2-customer-nodes&quot;&gt;Table 2: Customer Nodes&lt;/h3&gt;

&lt;p&gt;Customers are randomly distributed across the nodes according to their region - this also specifies exactly which node contains both their cash and data.&lt;/p&gt;

&lt;p&gt;This random distribution changes frequently to reduce the risk of hackers getting into Data Bank’s system and stealing customer’s money and data!&lt;/p&gt;

&lt;p&gt;Below is a sample of the top 10 rows of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;data_bank.customer_nodes&lt;/code&gt;&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;region_id&lt;/th&gt;
        &lt;th&gt;node_id&lt;/th&gt;
        &lt;th&gt;start_date&lt;/th&gt;
        &lt;th&gt;end_date&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-01-02&lt;/td&gt;
        &lt;td&gt;2020-01-03&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2020-01-03&lt;/td&gt;
        &lt;td&gt;2020-01-17&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-01-27&lt;/td&gt;
        &lt;td&gt;2020-02-18&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-01-07&lt;/td&gt;
        &lt;td&gt;2020-01-19&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2020-01-15&lt;/td&gt;
        &lt;td&gt;2020-01-23&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2020-01-11&lt;/td&gt;
        &lt;td&gt;2020-02-06&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2020-01-20&lt;/td&gt;
        &lt;td&gt;2020-02-04&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2020-01-15&lt;/td&gt;
        &lt;td&gt;2020-01-28&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;2020-01-21&lt;/td&gt;
        &lt;td&gt;2020-01-25&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-01-13&lt;/td&gt;
        &lt;td&gt;2020-01-14&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-3-customer-transactions&quot;&gt;Table 3: Customer Transactions&lt;/h3&gt;

&lt;p&gt;This table stores all customer deposits, withdrawals and purchases made using their Data Bank debit card.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;txn_date&lt;/th&gt;
        &lt;th&gt;txn_type&lt;/th&gt;
        &lt;th&gt;txn_amount&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;429&lt;/td&gt;
        &lt;td&gt;2020-01-21&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;82&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;155&lt;/td&gt;
        &lt;td&gt;2020-01-10&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;712&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;398&lt;/td&gt;
        &lt;td&gt;2020-01-01&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;196&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;255&lt;/td&gt;
        &lt;td&gt;2020-01-14&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;563&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;185&lt;/td&gt;
        &lt;td&gt;2020-01-29&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;626&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;309&lt;/td&gt;
        &lt;td&gt;2020-01-13&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;995&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;312&lt;/td&gt;
        &lt;td&gt;2020-01-20&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;485&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;376&lt;/td&gt;
        &lt;td&gt;2020-01-03&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;706&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;188&lt;/td&gt;
        &lt;td&gt;2020-01-13&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;601&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;138&lt;/td&gt;
        &lt;td&gt;2020-01-11&lt;/td&gt;
        &lt;td&gt;deposit&lt;/td&gt;
        &lt;td&gt;520&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students will have access to the same relevant schema SQL and example solutions which they can use with their Docker setup from within the course player!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
&lt;iframe src=&quot;https://embed.db-fiddle.com/18d82cef-a1ba-4fff-9a20-a41db3a637c7&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;The following case study questions include some general data exploration analysis for the nodes and transactions before diving right into the core business questions and finishes with a challenging final request!&lt;/p&gt;

&lt;h3 id=&quot;a-customer-nodes-exploration&quot;&gt;A. Customer Nodes Exploration&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;How many unique nodes are there on the Data Bank system?&lt;/li&gt;
  &lt;li&gt;What is the number of nodes per region?&lt;/li&gt;
  &lt;li&gt;How many customers are allocated to each region?&lt;/li&gt;
  &lt;li&gt;How many days on average are customers reallocated to a different node?&lt;/li&gt;
  &lt;li&gt;What is the median, 80th and 95th percentile for this same reallocation days metric for each region?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;b-customer-transactions&quot;&gt;B. Customer Transactions&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;What is the unique count and total amount for each transaction type?&lt;/li&gt;
  &lt;li&gt;What is the average total historical deposit counts and amounts for all customers?&lt;/li&gt;
  &lt;li&gt;For each month - how many Data Bank customers make more than 1 deposit and either 1 purchase or 1 withdrawal in a single month?&lt;/li&gt;
  &lt;li&gt;What is the closing balance for each customer at the end of the month?&lt;/li&gt;
  &lt;li&gt;What is the percentage of customers who increase their closing balance by more than 5%?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;c-data-allocation-challenge&quot;&gt;C. Data Allocation Challenge&lt;/h3&gt;

&lt;p&gt;To test out a few different hypotheses - the Data Bank team wants to run an experiment where different groups of customers would be allocated data using 3 different options:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Option 1: data is allocated based off the amount of money at the end of the previous month&lt;/li&gt;
  &lt;li&gt;Option 2: data is allocated on the average amount of money kept in the account in the previous 30 days&lt;/li&gt;
  &lt;li&gt;Option 3: data is updated real-time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this multi-part challenge question - you have been requested to generate the following data elements to help the Data Bank team estimate how much data will need to be provisioned for each option:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;running customer balance column that includes the impact each transaction&lt;/li&gt;
  &lt;li&gt;customer balance at the end of each month&lt;/li&gt;
  &lt;li&gt;minimum, average and maximum values of the running balance for each customer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Using all of the data available - how much data would have been required for each option on a monthly basis?&lt;/p&gt;

&lt;h3 id=&quot;d-extra-challenge&quot;&gt;D. Extra Challenge&lt;/h3&gt;

&lt;p&gt;Data Bank wants to try another option which is a bit more difficult to implement - they want to calculate data growth using an interest calculation, just like in a traditional savings account you might have with a bank.&lt;/p&gt;

&lt;p&gt;If the annual interest rate is set at 6% and the Data Bank team wants to reward its customers by increasing their data allocation based off the interest calculated on a daily basis at the end of each day, how much data would be required for this option on a monthly basis?&lt;/p&gt;

&lt;p&gt;Special notes:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Data Bank wants an initial calculation which does not allow for compounding interest, however they may also be interested in a daily compounding interest calculation so you can try to perform this calculation if you have the stamina!&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;extension-request&quot;&gt;Extension Request&lt;/h3&gt;

&lt;p&gt;The Data Bank team wants you to use the outputs generated from the above sections to create a quick Powerpoint presentation which will be used as marketing materials for both external investors who might want to buy Data Bank shares and new prospective customers who might want to bank with Data Bank.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Using the outputs generated from the customer node questions, generate a few headline insights which Data Bank might use to market it’s world-leading security features to potential investors and customers.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;With the transaction analysis - prepare a 1 page presentation slide which contains all the relevant information about the various options for the data provisioning so the Data Bank management team can make an informed decision.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This case study aims to mimic traditional banking style transactions data but with a twist - hopefully it can give you some insight into the types of datasets you might encounter in a customer banking scenario.&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #5!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-5&quot;&gt;&lt;img src=&quot;/images/case-study-designs/5.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/4.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/4.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #3 - Foodie-Fi</title><link href="http://www.8weeksqlchallenge.com/case-study-3/" rel="alternate" type="text/html" title="Case Study #3 - Foodie-Fi" /><published>2021-05-18T00:00:00+00:00</published><updated>2021-05-18T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-3</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-3/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/3.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Subscription based businesses are super popular and Danny realised that there was a large gap in the market - he wanted to create a new streaming service that only had food related content - something like Netflix but with only cooking shows!&lt;/p&gt;

&lt;p&gt;Danny finds a few smart friends to launch his new startup Foodie-Fi in 2020 and started selling monthly and annual subscriptions, giving their customers unlimited on-demand access to exclusive food videos from around the world!&lt;/p&gt;

&lt;p&gt;Danny created Foodie-Fi with a data driven mindset and wanted to ensure all future investment decisions and new features were decided using data. This case study focuses on using subscription style digital data to answer important business questions.&lt;/p&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;Danny has shared the data design for Foodie-Fi and also short descriptions on each of the database tables - our case study focuses on only 2 tables but there will be a challenge to create a new table for the Foodie-Fi team.&lt;/p&gt;

&lt;p&gt;All datasets exist within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;foodie_fi&lt;/code&gt; database schema - be sure to include this reference within your SQL scripts as you start exploring the data and answering the case study questions.&lt;/p&gt;

&lt;h3 id=&quot;entity-relationship-diagram&quot;&gt;Entity Relationship Diagram&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/images/case-study-3-erd.png&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;table-1-plans&quot;&gt;Table 1: plans&lt;/h3&gt;

&lt;p&gt;Customers can choose which plans to join Foodie-Fi when they first sign up.&lt;/p&gt;

&lt;p&gt;Basic plan customers have limited access and can only stream their videos and is only available monthly at $9.90&lt;/p&gt;

&lt;p&gt;Pro plan customers have no watch time limits and are able to download videos for offline viewing. Pro plans start at $19.90 a month or $199 for an annual subscription.&lt;/p&gt;

&lt;p&gt;Customers can sign up to an initial 7 day free trial will automatically continue with the pro monthly subscription plan unless they cancel, downgrade to basic or upgrade to an annual pro plan at any point during the trial.&lt;/p&gt;

&lt;p&gt;When customers cancel their Foodie-Fi service - they will have a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;churn&lt;/code&gt; plan record with a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; price but their plan will continue until the end of the billing period.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;plan_id&lt;/th&gt;
        &lt;th&gt;plan_name&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;trial&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;pro annual&lt;/td&gt;
        &lt;td&gt;199&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;churn&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-2-subscriptions&quot;&gt;Table 2: subscriptions&lt;/h3&gt;

&lt;p&gt;Customer subscriptions show the exact date where their specific &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plan_id&lt;/code&gt; starts.&lt;/p&gt;

&lt;p&gt;If customers downgrade from a pro plan or cancel their subscription - the higher plan will remain in place until the period is over - the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_date&lt;/code&gt; in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subscriptions&lt;/code&gt; table will reflect the date that the actual plan  changes.&lt;/p&gt;

&lt;p&gt;When customers upgrade their account from a basic plan to a pro or annual pro plan - the higher plan will take effect straightaway.&lt;/p&gt;

&lt;p&gt;When customers churn - they will keep their access until the end of their current billing period but the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_date&lt;/code&gt; will be technically the day they decided to cancel their service.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;plan_id&lt;/th&gt;
        &lt;th&gt;start_date&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-08-01&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2020-08-08&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-09-20&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2020-09-27&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-11-19&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-11-26&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-12-15&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2020-12-22&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2021-03-29&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-03-17&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2020-03-24&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2020-04-29&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-05-31&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2020-06-07&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2020-10-21&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-07-06&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2020-07-13&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;0&lt;/td&gt;
        &lt;td&gt;2020-06-22&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2020-06-29&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2020-08-29&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students will have access to the same relevant schema SQL and example solutions which they can use with their Docker setup from within the course player!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
&lt;iframe src=&quot;https://embed.db-fiddle.com/385cbacc-36ad-46c4-978b-1cf5795b41bd&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;This case study is split into an initial data understanding question before diving straight into data analysis questions before finishing with 1 single extension challenge.&lt;/p&gt;

&lt;h3 id=&quot;a-customer-journey&quot;&gt;A. Customer Journey&lt;/h3&gt;

&lt;p&gt;Based off the 8 sample customers provided in the sample from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subscriptions&lt;/code&gt; table, write a brief description about each customer’s onboarding journey.&lt;/p&gt;

&lt;p&gt;Try to keep it as short as possible - you may also want to run some sort of join to make your explanations a bit easier!&lt;/p&gt;

&lt;h3 id=&quot;b-data-analysis-questions&quot;&gt;B. Data Analysis Questions&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;How many customers has Foodie-Fi ever had?&lt;/li&gt;
  &lt;li&gt;What is the monthly distribution of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;trial&lt;/code&gt; plan &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_date&lt;/code&gt; values for our dataset - use the start of the month as the group by value&lt;/li&gt;
  &lt;li&gt;What plan &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_date&lt;/code&gt; values occur after the year 2020 for our dataset? Show the breakdown by count of events for each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plan_name&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;What is the customer count and percentage of customers who have churned rounded to 1 decimal place?&lt;/li&gt;
  &lt;li&gt;How many customers have churned straight after their initial free trial - what percentage is this rounded to the nearest whole number?&lt;/li&gt;
  &lt;li&gt;What is the number and percentage of customer plans after their initial free trial?&lt;/li&gt;
  &lt;li&gt;What is the customer count and percentage breakdown of all 5 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plan_name&lt;/code&gt; values at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2020-12-31&lt;/code&gt;?&lt;/li&gt;
  &lt;li&gt;How many customers have upgraded to an annual plan in 2020?&lt;/li&gt;
  &lt;li&gt;How many days on average does it take for a customer to an annual plan from the day they join Foodie-Fi?&lt;/li&gt;
  &lt;li&gt;Can you further breakdown this average value into 30 day periods (i.e. 0-30 days, 31-60 days etc)&lt;/li&gt;
  &lt;li&gt;How many customers downgraded from a pro monthly to a basic monthly plan in 2020?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;c-challenge-payment-question&quot;&gt;C. Challenge Payment Question&lt;/h3&gt;

&lt;p&gt;The Foodie-Fi team wants you to create a new &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;payments&lt;/code&gt; table for the year 2020 that includes amounts paid by each customer in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;subscriptions&lt;/code&gt; table with the following requirements:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;monthly payments always occur on the same day of month as the original &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;start_date&lt;/code&gt; of any monthly paid plan&lt;/li&gt;
  &lt;li&gt;upgrades from basic to monthly or pro plans are reduced by the current paid amount in that month and start immediately&lt;/li&gt;
  &lt;li&gt;upgrades from pro monthly to pro annual are paid at the end of the current billing period and also starts at the end of the month period&lt;/li&gt;
  &lt;li&gt;once a customer churns they will no longer make payments&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example outputs for this table might look like the following:&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;plan_id&lt;/th&gt;
        &lt;th&gt;plan_name&lt;/th&gt;
        &lt;th&gt;payment_date&lt;/th&gt;
        &lt;th&gt;amount&lt;/th&gt;
        &lt;th&gt;payment_order&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-08-08&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-09-08&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-10-08&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-11-08&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-12-08&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;pro annual&lt;/td&gt;
        &lt;td&gt;2020-09-27&lt;/td&gt;
        &lt;td&gt;199.00&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-12-22&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-03-24&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-04-24&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-06-07&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-07-07&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-08-07&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-09-07&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;basic monthly&lt;/td&gt;
        &lt;td&gt;2020-10-07&lt;/td&gt;
        &lt;td&gt;9.90&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;16&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;pro annual&lt;/td&gt;
        &lt;td&gt;2020-10-21&lt;/td&gt;
        &lt;td&gt;189.10&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-07-13&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-08-13&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-09-13&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-10-13&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-11-13&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;5&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-12-13&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;6&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-06-29&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;pro monthly&lt;/td&gt;
        &lt;td&gt;2020-07-29&lt;/td&gt;
        &lt;td&gt;19.90&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;19&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;pro annual&lt;/td&gt;
        &lt;td&gt;2020-08-29&lt;/td&gt;
        &lt;td&gt;199.00&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;d-outside-the-box-questions&quot;&gt;D. Outside The Box Questions&lt;/h3&gt;

&lt;p&gt;The following are open ended questions which might be asked during a technical interview for this case study - there are no right or wrong answers, but answers that make sense from both a technical and a business perspective make an amazing impression!&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;How would you calculate the rate of growth for Foodie-Fi?&lt;/li&gt;
  &lt;li&gt;What key metrics would you recommend Foodie-Fi management to track over time to assess performance of their overall business?&lt;/li&gt;
  &lt;li&gt;What are some key customer journeys or experiences that you would analyse further to improve customer retention?&lt;/li&gt;
  &lt;li&gt;If the Foodie-Fi team were to create an exit survey shown to customers who wish to cancel their subscription, what questions would you include in the survey?&lt;/li&gt;
  &lt;li&gt;What business levers could the Foodie-Fi team use to reduce the customer churn rate? How would you validate the effectiveness of your ideas?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This case study should reflect realistic questions we usually focus on for all product related analytics requests in a wide variety of industries, especially in the digital space!&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #4!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-4&quot;&gt;&lt;img src=&quot;/images/case-study-designs/4.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/3.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/3.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #2 - Pizza Runner</title><link href="http://www.8weeksqlchallenge.com/case-study-2/" rel="alternate" type="text/html" title="Case Study #2 - Pizza Runner" /><published>2021-05-04T00:00:00+00:00</published><updated>2021-05-04T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-2</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-2/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/2.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Did you know that over &lt;strong&gt;115 million kilograms&lt;/strong&gt; of pizza is consumed daily worldwide??? (Well according to Wikipedia anyway…)&lt;/p&gt;

&lt;p&gt;Danny was scrolling through his Instagram feed when something really caught his eye - “80s Retro Styling and Pizza Is The Future!”&lt;/p&gt;

&lt;p&gt;Danny was sold on the idea, but he knew that pizza alone was not going to help him get seed funding to expand his new Pizza Empire - so he had one more genius idea to combine with it - he was going to &lt;em&gt;Uberize&lt;/em&gt; it - and so Pizza Runner was launched!&lt;/p&gt;

&lt;p&gt;Danny started by recruiting “runners” to deliver fresh pizza from Pizza Runner Headquarters (otherwise known as Danny’s house) and also maxed out his credit card to pay freelance developers to build a mobile app to accept orders from customers.&lt;/p&gt;

&lt;h2 id=&quot;available-data&quot;&gt;Available Data&lt;/h2&gt;

&lt;p&gt;Because Danny had a few years of experience as a data scientist - he was very aware that data collection was going to be critical for his business’ growth.&lt;/p&gt;

&lt;p&gt;He has prepared for us an entity relationship diagram of his database design but requires further assistance to clean his data and apply some basic calculations so he can better direct his runners and optimise Pizza Runner’s operations.&lt;/p&gt;

&lt;p&gt;All datasets exist within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pizza_runner&lt;/code&gt; database schema - be sure to include this reference within your SQL scripts as you start exploring the data and answering the case study questions.&lt;/p&gt;

&lt;h3 id=&quot;entity-relationship-diagram&quot;&gt;Entity Relationship Diagram&lt;/h3&gt;

&lt;div class=&quot;dbdiagram-container&quot;&gt;
  &lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https://dbdiagram.io/embed/5f3e085ccf48a141ff558487&quot;&gt; &lt;/iframe&gt;
&lt;/div&gt;

&lt;h3 id=&quot;table-1-runners&quot;&gt;Table 1: runners&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;runners&lt;/code&gt; table shows the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;registration_date&lt;/code&gt; for each new runner&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;runner_id&lt;/th&gt;
      &lt;th&gt;registration_date&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;2021-01-01&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;2021-01-03&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;2021-01-08&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;2021-01-15&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;table-2-customer_orders&quot;&gt;Table 2: customer_orders&lt;/h3&gt;

&lt;p&gt;Customer pizza orders are captured in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_orders&lt;/code&gt; table with 1 row for each individual pizza that is part of the order.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pizza_id&lt;/code&gt; relates to the type of pizza which was ordered whilst the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exclusions&lt;/code&gt; are the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ingredient_id&lt;/code&gt; values which should be removed from the pizza and the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;extras&lt;/code&gt; are the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ingredient_id&lt;/code&gt; values which need to be added to the pizza.&lt;/p&gt;

&lt;p&gt;Note that customers can order multiple pizzas in a single order with varying &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exclusions&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;extras&lt;/code&gt; values even if the pizza is the same type!&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;exclusions&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;extras&lt;/code&gt; columns will need to be cleaned up before using them in your queries.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;order_id&lt;/th&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;pizza_id&lt;/th&gt;
        &lt;th&gt;exclusions&lt;/th&gt;
        &lt;th&gt;extras&lt;/th&gt;
        &lt;th&gt;order_time&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;101&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;2021-01-01 18:05:02&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;101&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;2021-01-01 19:00:52&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;102&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;2021-01-02 23:51:23&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;102&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;NaN&lt;/td&gt;
        &lt;td&gt;2021-01-02 23:51:23&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;103&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;2021-01-04 13:23:46&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;103&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;2021-01-04 13:23:46&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;103&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
        &lt;td&gt;2021-01-04 13:23:46&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;104&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2021-01-08 21:00:29&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;101&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;2021-01-08 21:03:13&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;105&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2021-01-08 21:20:29&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;102&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;2021-01-09 23:54:33&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;103&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;1, 5&lt;/td&gt;
        &lt;td&gt;2021-01-10 11:22:59&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;104&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;2021-01-11 18:34:49&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;104&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2, 6&lt;/td&gt;
        &lt;td&gt;1, 4&lt;/td&gt;
        &lt;td&gt;2021-01-11 18:34:49&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-3-runner_orders&quot;&gt;Table 3: runner_orders&lt;/h3&gt;

&lt;p&gt;After each orders are received through the system - they are assigned to a runner - however not all orders are fully completed and can be cancelled by the restaurant or the customer.&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pickup_time&lt;/code&gt; is the timestamp at which the runner arrives at the Pizza Runner headquarters to pick up the freshly cooked pizzas. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;distance&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;duration&lt;/code&gt; fields are related to how far and long the runner had to travel to deliver the order to the respective customer.&lt;/p&gt;

&lt;p&gt;There are some known data issues with this table so be careful when using this in your queries - make sure to check the data types for each column in the schema SQL!&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;order_id&lt;/th&gt;
        &lt;th&gt;runner_id&lt;/th&gt;
        &lt;th&gt;pickup_time&lt;/th&gt;
        &lt;th&gt;distance&lt;/th&gt;
        &lt;th&gt;duration&lt;/th&gt;
        &lt;th&gt;cancellation&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2021-01-01 18:15:34&lt;/td&gt;
        &lt;td&gt;20km&lt;/td&gt;
        &lt;td&gt;32 minutes&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2021-01-01 19:10:54&lt;/td&gt;
        &lt;td&gt;20km&lt;/td&gt;
        &lt;td&gt;27 minutes&lt;/td&gt;
        &lt;td&gt; &lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2021-01-03 00:12:37&lt;/td&gt;
        &lt;td&gt;13.4km&lt;/td&gt;
        &lt;td&gt;20 mins&lt;/td&gt;
        &lt;td&gt;NaN&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2021-01-04 13:53:03&lt;/td&gt;
        &lt;td&gt;23.4&lt;/td&gt;
        &lt;td&gt;40&lt;/td&gt;
        &lt;td&gt;NaN&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;2021-01-08 21:10:57&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;NaN&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;Restaurant Cancellation&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2020-01-08 21:30:45&lt;/td&gt;
        &lt;td&gt;25km&lt;/td&gt;
        &lt;td&gt;25mins&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;2020-01-10 00:15:02&lt;/td&gt;
        &lt;td&gt;23.4 km&lt;/td&gt;
        &lt;td&gt;15 minute&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
        &lt;td&gt;Customer Cancellation&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;2020-01-11 18:50:20&lt;/td&gt;
        &lt;td&gt;10km&lt;/td&gt;
        &lt;td&gt;10minutes&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-4-pizza_names&quot;&gt;Table 4: pizza_names&lt;/h3&gt;

&lt;p&gt;At the moment - Pizza Runner only has 2 pizzas available the Meat Lovers or Vegetarian!&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;pizza_id&lt;/th&gt;
        &lt;th&gt;pizza_name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Meat Lovers&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;Vegetarian&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-5-pizza_recipes&quot;&gt;Table 5: pizza_recipes&lt;/h3&gt;

&lt;p&gt;Each &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pizza_id&lt;/code&gt; has a standard set of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;toppings&lt;/code&gt; which are used as part of the pizza recipe.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;pizza_id&lt;/th&gt;
        &lt;th&gt;toppings&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;1, 2, 3, 4, 5, 6, 8, 10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;4, 6, 7, 9, 11, 12&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-6-pizza_toppings&quot;&gt;Table 6: pizza_toppings&lt;/h3&gt;

&lt;p&gt;This table contains all of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topping_name&lt;/code&gt; values with their corresponding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;topping_id&lt;/code&gt; value&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;topping_id&lt;/th&gt;
        &lt;th&gt;topping_name&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;Bacon&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;BBQ Sauce&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;Beef&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;Cheese&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;5&lt;/td&gt;
        &lt;td&gt;Chicken&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;6&lt;/td&gt;
        &lt;td&gt;Mushrooms&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;7&lt;/td&gt;
        &lt;td&gt;Onions&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;8&lt;/td&gt;
        &lt;td&gt;Pepperoni&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;9&lt;/td&gt;
        &lt;td&gt;Peppers&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Salami&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;Tomatoes&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Tomato Sauce&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-instance&quot;&gt;Interactive SQL Instance&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students can copy and paste the Schema SQL code below directly into their SQLPad GUI to create permanent tables or they can add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TEMP&lt;/code&gt; within the table creation steps like we’ve done throughout the entire course to keep our schemas clean and tidy!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
&lt;iframe src=&quot;https://embed.db-fiddle.com/3394804c-9714-470d-884f-99dd25e9a1f0&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;This case study has &lt;strong&gt;LOTS&lt;/strong&gt; of questions - they are broken up by area of focus including:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Pizza Metrics&lt;/li&gt;
  &lt;li&gt;Runner and Customer Experience&lt;/li&gt;
  &lt;li&gt;Ingredient Optimisation&lt;/li&gt;
  &lt;li&gt;Pricing and Ratings&lt;/li&gt;
  &lt;li&gt;Bonus DML Challenges (DML = Data Manipulation Language)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of the following case study questions can be answered using a single SQL statement.&lt;/p&gt;

&lt;p&gt;Again, there are many questions in this case study - please feel free to pick and choose which ones you’d like to try!&lt;/p&gt;

&lt;p&gt;Before you start writing your SQL queries however - you might want to investigate the data, you may want to do something with some of those &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt; values and data types in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_orders&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;runner_orders&lt;/code&gt; tables!&lt;/p&gt;

&lt;h3 id=&quot;a-pizza-metrics&quot;&gt;A. Pizza Metrics&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;How many pizzas were ordered?&lt;/li&gt;
  &lt;li&gt;How many unique customer orders were made?&lt;/li&gt;
  &lt;li&gt;How many successful orders were delivered by each runner?&lt;/li&gt;
  &lt;li&gt;How many of each type of pizza was delivered?&lt;/li&gt;
  &lt;li&gt;How many Vegetarian and Meatlovers were ordered by each customer?&lt;/li&gt;
  &lt;li&gt;What was the maximum number of pizzas delivered in a single order?&lt;/li&gt;
  &lt;li&gt;For each customer, how many delivered pizzas had at least 1 change and how many had no changes?&lt;/li&gt;
  &lt;li&gt;How many pizzas were delivered that had both exclusions and extras?&lt;/li&gt;
  &lt;li&gt;What was the total volume of pizzas ordered for each hour of the day?&lt;/li&gt;
  &lt;li&gt;What was the volume of orders for each day of the week?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;b-runner-and-customer-experience&quot;&gt;B. Runner and Customer Experience&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;How many runners signed up for each 1 week period? (i.e. week starts &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2021-01-01&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;What was the average time in minutes it took for each runner to arrive at the Pizza Runner HQ to pickup the order?&lt;/li&gt;
  &lt;li&gt;Is there any relationship between the number of pizzas and how long the order takes to prepare?&lt;/li&gt;
  &lt;li&gt;What was the average distance travelled for each customer?&lt;/li&gt;
  &lt;li&gt;What was the difference between the longest and shortest delivery times for all orders?&lt;/li&gt;
  &lt;li&gt;What was the average speed for each runner for each delivery and do you notice any trend for these values?&lt;/li&gt;
  &lt;li&gt;What is the successful delivery percentage for each runner?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;c-ingredient-optimisation&quot;&gt;C. Ingredient Optimisation&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;What are the standard ingredients for each pizza?&lt;/li&gt;
  &lt;li&gt;What was the most commonly added extra?&lt;/li&gt;
  &lt;li&gt;What was the most common exclusion?&lt;/li&gt;
  &lt;li&gt;Generate an order item for each record in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customers_orders&lt;/code&gt; table in the format of one of the following:
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Meat Lovers&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Meat Lovers - Exclude Beef&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Meat Lovers - Extra Bacon&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Meat Lovers - Exclude Cheese, Bacon - Extra Mushroom, Peppers&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Generate an alphabetically ordered comma separated ingredient list for each pizza order from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_orders&lt;/code&gt; table and add a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2x&lt;/code&gt; in front of any relevant ingredients
    &lt;ul&gt;
      &lt;li&gt;For example: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&quot;Meat Lovers: 2xBacon, Beef, ... , Salami&quot;&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;What is the total quantity of each ingredient used in all delivered pizzas sorted by most frequent first?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;d-pricing-and-ratings&quot;&gt;D. Pricing and Ratings&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;If a Meat Lovers pizza costs $12 and Vegetarian costs $10 and there were no charges for changes - how much money has Pizza Runner made so far if there are no delivery fees?&lt;/li&gt;
  &lt;li&gt;What if there was an additional $1 charge for any pizza extras?
    &lt;ul&gt;
      &lt;li&gt;Add cheese is $1 extra&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;The Pizza Runner team now wants to add an additional ratings system that allows customers to rate their runner, how would you design an additional table for this new dataset - generate a schema for this new table and insert your own data for ratings for each successful customer order between 1 to 5.&lt;/li&gt;
  &lt;li&gt;Using your newly generated table - can you join all of the information together to form a table which has the following information for successful deliveries?
    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_id&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;order_id&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;runner_id&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rating&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;order_time&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pickup_time&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Time between order and pickup&lt;/li&gt;
      &lt;li&gt;Delivery duration&lt;/li&gt;
      &lt;li&gt;Average speed&lt;/li&gt;
      &lt;li&gt;Total number of pizzas&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;If a Meat Lovers pizza was $12 and Vegetarian $10 fixed prices with no cost for extras and each runner is paid $0.30 per kilometre traveled - how much money does Pizza Runner have left over after these deliveries?&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;e-bonus-questions&quot;&gt;E. Bonus Questions&lt;/h3&gt;

&lt;p&gt;If Danny wants to expand his range of pizzas - how would this impact the existing data design? Write an &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;INSERT&lt;/code&gt; statement to demonstrate what would happen if a new &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Supreme&lt;/code&gt; pizza with all the toppings was added to the Pizza Runner menu?&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I hope there were enough case study questions to keep you occupied - I kinda went out all out in this case study!&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #3!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-3&quot;&gt;&lt;img src=&quot;/images/case-study-designs/3.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;p&gt;The following topics relevant to the Pizza Runner case study are covered lots of depth in the Serious SQL course:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Common table expressions&lt;/li&gt;
  &lt;li&gt;Group by aggregates&lt;/li&gt;
  &lt;li&gt;Table joins&lt;/li&gt;
  &lt;li&gt;String transformations&lt;/li&gt;
  &lt;li&gt;Dealing with null values&lt;/li&gt;
  &lt;li&gt;Regular expressions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don’t forget to review the comprehensive list of SQL resources I’ve put together for the 8 Week SQL Challenge on the &lt;a href=&quot;/resources&quot;&gt;Resources&lt;/a&gt; page!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/2.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/2.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry><entry><title type="html">Case Study #1 - Danny’s Diner</title><link href="http://www.8weeksqlchallenge.com/case-study-1/" rel="alternate" type="text/html" title="Case Study #1 - Danny’s Diner" /><published>2021-05-01T00:00:00+00:00</published><updated>2021-05-01T00:00:00+00:00</updated><id>http://www.8weeksqlchallenge.com/case-study-1</id><content type="html" xml:base="http://www.8weeksqlchallenge.com/case-study-1/">&lt;p&gt;&lt;img src=&quot;/images/case-study-designs/1.png&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;introduction&quot;&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Danny seriously loves Japanese food so in the beginning of 2021, he decides to embark upon a risky venture and opens up a cute little restaurant that sells his 3 favourite foods: sushi, curry and ramen.&lt;/p&gt;

&lt;p&gt;Danny’s Diner is in need of your assistance to help the restaurant stay afloat - the restaurant has captured some very basic data from their few months of operation but have no idea how to use their data to help them run the business.&lt;/p&gt;

&lt;h2 id=&quot;problem-statement&quot;&gt;Problem Statement&lt;/h2&gt;

&lt;p&gt;Danny wants to use the data to answer a few simple questions about his customers, especially about their visiting patterns, how much money they’ve spent and also which menu items are their favourite. Having this deeper connection with his customers will help him deliver a better and more personalised experience for his loyal customers.&lt;/p&gt;

&lt;p&gt;He plans on using these insights to help him decide whether he should expand the existing customer loyalty program - additionally he needs help to generate some basic datasets so his team can easily inspect the data without needing to use SQL.&lt;/p&gt;

&lt;p&gt;Danny has provided you with a sample of his overall customer data due to privacy issues - but he hopes that these examples are enough for you to write fully functioning SQL queries to help him answer his questions!&lt;/p&gt;

&lt;p&gt;Danny has shared with you 3 key datasets for this case study:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sales&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;menu&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;members&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can inspect the entity relationship diagram and example data below.&lt;/p&gt;

&lt;h2 id=&quot;entity-relationship-diagram&quot;&gt;Entity Relationship Diagram&lt;/h2&gt;

&lt;div class=&quot;dbdiagram-container&quot;&gt;
&lt;iframe src=&quot;https://dbdiagram.io/embed/608d07e4b29a09603d12edbd&quot;&gt; &lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;example-datasets&quot;&gt;Example Datasets&lt;/h2&gt;

&lt;p&gt;All datasets exist within the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dannys_diner&lt;/code&gt; database schema - be sure to include this reference within your SQL scripts as you start exploring the data and answering the case study questions.&lt;/p&gt;

&lt;h3 id=&quot;table-1-sales&quot;&gt;Table 1: sales&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sales&lt;/code&gt; table captures all &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_id&lt;/code&gt; level purchases with an corresponding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;order_date&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_id&lt;/code&gt; information for when and what menu items were ordered.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;order_date&lt;/th&gt;
        &lt;th&gt;product_id&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-10&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-02&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-04&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-16&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-02-01&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-2-menu&quot;&gt;Table 2: menu&lt;/h3&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;menu&lt;/code&gt; table maps the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_id&lt;/code&gt; to the actual &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;product_name&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;price&lt;/code&gt; of each menu item.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;product_id&lt;/th&gt;
        &lt;th&gt;product_name&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;1&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;2&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;3&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;table-3-members&quot;&gt;Table 3: members&lt;/h3&gt;

&lt;p&gt;The final &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;members&lt;/code&gt; table captures the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;join_date&lt;/code&gt; when a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;customer_id&lt;/code&gt; joined the beta version of the Danny’s Diner loyalty program.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;join_date&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-09&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;interactive-sql-session&quot;&gt;Interactive SQL Session&lt;/h2&gt;

&lt;p&gt;You can use the embedded DB Fiddle below to easily access these example datasets - this interactive session has everything you need to start solving these questions using SQL.&lt;/p&gt;

&lt;p&gt;You can click on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Edit on DB Fiddle&lt;/code&gt; link on the top right hand corner of the embedded session below and it will take you to a fully functional SQL editor where you can write your own queries to analyse the data.&lt;/p&gt;

&lt;p&gt;You can feel free to choose any SQL dialect you’d like to use, the existing Fiddle is using PostgreSQL 13 as default.&lt;/p&gt;

&lt;p&gt;Serious SQL students have access to a dedicated SQL script in the 8 Week SQL Challenge section of the course which they can use to generate relevant temporary tables like we’ve done throughout the entire course!&lt;/p&gt;

&lt;div class=&quot;sqlfiddle-container&quot;&gt;
  &lt;iframe src=&quot;https://embed.db-fiddle.com/912b55b7-0c69-4f19-906f-aaef8ece6088&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot; title=&quot;Embedded fiddle&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

&lt;h2 id=&quot;case-study-questions&quot;&gt;Case Study Questions&lt;/h2&gt;

&lt;p&gt;Each of the following case study questions can be answered using a single SQL statement:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;What is the total amount each customer spent at the restaurant?&lt;/li&gt;
  &lt;li&gt;How many days has each customer visited the restaurant?&lt;/li&gt;
  &lt;li&gt;What was the first item from the menu purchased by each customer?&lt;/li&gt;
  &lt;li&gt;What is the most purchased item on the menu and how many times was it purchased by all customers?&lt;/li&gt;
  &lt;li&gt;Which item was the most popular for each customer?&lt;/li&gt;
  &lt;li&gt;Which item was purchased first by the customer after they became a member?&lt;/li&gt;
  &lt;li&gt;Which item was purchased just before the customer became a member?&lt;/li&gt;
  &lt;li&gt;What is the total items and amount spent for each member before they became a member?&lt;/li&gt;
  &lt;li&gt;If each $1 spent equates to 10 points and sushi has a 2x points multiplier - how many points would each customer have?&lt;/li&gt;
  &lt;li&gt;In the first week after a customer joins the program (including their join date) they earn 2x points on all items, not just sushi - how many points do customer A and B have at the end of January?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;bonus-questions&quot;&gt;Bonus Questions&lt;/h2&gt;

&lt;h3 id=&quot;join-all-the-things&quot;&gt;Join All The Things&lt;/h3&gt;

&lt;p&gt;The following questions are related creating basic data tables that Danny and his team can use to quickly derive insights without needing to join the underlying tables using SQL.&lt;/p&gt;

&lt;p&gt;Recreate the following table output using the available data:&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;order_date&lt;/th&gt;
        &lt;th&gt;product_name&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
        &lt;th&gt;member&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-10&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-02&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-04&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-16&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-02-01&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h3 id=&quot;rank-all-the-things&quot;&gt;Rank All The Things&lt;/h3&gt;

&lt;p&gt;Danny also requires further information about the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ranking&lt;/code&gt; of customer products, but he purposely does not need the ranking for non-member purchases so he expects null &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ranking&lt;/code&gt; values for the records when customers are not yet part of the loyalty program.&lt;/p&gt;

&lt;div class=&quot;responsive-table&quot;&gt;

  &lt;table&gt;
    &lt;thead&gt;
      &lt;tr&gt;
        &lt;th&gt;customer_id&lt;/th&gt;
        &lt;th&gt;order_date&lt;/th&gt;
        &lt;th&gt;product_name&lt;/th&gt;
        &lt;th&gt;price&lt;/th&gt;
        &lt;th&gt;member&lt;/th&gt;
        &lt;th&gt;ranking&lt;/th&gt;
      &lt;/tr&gt;
    &lt;/thead&gt;
    &lt;tbody&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-10&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;A&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-02&lt;/td&gt;
        &lt;td&gt;curry&lt;/td&gt;
        &lt;td&gt;15&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-04&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-11&lt;/td&gt;
        &lt;td&gt;sushi&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;1&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-01-16&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;2&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;B&lt;/td&gt;
        &lt;td&gt;2021-02-01&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;Y&lt;/td&gt;
        &lt;td&gt;3&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-01&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td&gt;C&lt;/td&gt;
        &lt;td&gt;2021-01-07&lt;/td&gt;
        &lt;td&gt;ramen&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;N&lt;/td&gt;
        &lt;td&gt;null&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/tbody&gt;
  &lt;/table&gt;

&lt;/div&gt;

&lt;h2 id=&quot;next-steps&quot;&gt;Next Steps&lt;/h2&gt;

&lt;p&gt;It’s highly recommended to save all of your code in a separate IDE or text editor as you are trying to solve the problems in the provided SQL Fiddle instance above!&lt;/p&gt;

&lt;p&gt;If you’d like to use this case study for one of your portfolio projects or in a personal blog post - please remember to link back to this URL and also don’t forget to share some LinkedIn updates using the &lt;strong&gt;#8WeekSQLChallenge&lt;/strong&gt; hashtag and remember to tag me!&lt;/p&gt;

&lt;p&gt;Ready for the next 8 Week SQL challenge case study? Click on the banner below to get started with case study #2!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/case-study-2&quot;&gt;&lt;img src=&quot;/images/case-study-designs/2.png&quot; alt=&quot;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I really hope you enjoyed this fun little case study - it definitely was fun for me to create!&lt;/p&gt;

&lt;h3 id=&quot;official-solutions&quot;&gt;Official Solutions&lt;/h3&gt;

&lt;p&gt;If you’d like to see the official code solutions and explanations for this case study and a whole lot more, please consider joining me for the &lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL course&lt;/a&gt; - you’ll get access to all course materials and I’m on hand to answer all of your additional SQL questions directly!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://bit.ly/3gWUT2G&quot;&gt;Serious SQL&lt;/a&gt; is priced at $49USD and $29 for students and includes access to all written course content, community events as well as live and recorded SQL training videos!&lt;/p&gt;

&lt;p&gt;Please send an email to support@datawithdanny.com from your educational email or include your enrolment details or student identification for a speedy response!&lt;/p&gt;

&lt;p&gt;The following topics relevant to the Danny’s Diner case study are covered lots of depth in the Serious SQL course:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Common Table Expressions&lt;/li&gt;
  &lt;li&gt;Group By Aggregates&lt;/li&gt;
  &lt;li&gt;Window Functions for ranking&lt;/li&gt;
  &lt;li&gt;Table Joins&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don’t forget to review the comprehensive list of SQL resources I’ve put together for the 8 Week SQL Challenge on the &lt;a href=&quot;/resources&quot;&gt;Resources&lt;/a&gt; page!&lt;/p&gt;

&lt;h3 id=&quot;community-solutions&quot;&gt;Community Solutions&lt;/h3&gt;

&lt;p&gt;This section will be updated in the future with any community member solutions with a link to their respective GitHub repos!&lt;/p&gt;

&lt;h3 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h3&gt;

&lt;p&gt;The 8 Week SQL Challenge is proudly brought to you by me - Danny Ma and the &lt;a href=&quot;https://bit.ly/datawithdanny-8wsc&quot;&gt;Data With Danny&lt;/a&gt; virtual data apprenticeship program.&lt;/p&gt;

&lt;p&gt;Students or anyone undertaking further studies are eligible for a $20USD student discount off the price of Serious SQL please send an email to support@datawithdanny.com from your education email or include information about your enrolment for a fast response!&lt;/p&gt;

&lt;p&gt;We have a large student community active on the official DWD Discord server with regular live events, trainings and workshops available to all Data With Danny students, plus early discounted access to all future paid courses.&lt;/p&gt;

&lt;p&gt;There are also opportunities for 1:1 mentoring, resume reviews, interview training and more from myself or others in the DWD Mentor Team.&lt;/p&gt;

&lt;p&gt;From your friendly data mentor,
Danny :)&lt;/p&gt;

&lt;h3 id=&quot;all-8-week-sql-challenge-case-studies&quot;&gt;All 8 Week SQL Challenge Case Studies&lt;/h3&gt;

&lt;p&gt;All of the 8 Week SQL Challenge case studies can be found below:&lt;/p&gt;

&lt;ul&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-1/&quot;&gt;Case Study #1 - Danny's Diner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-2/&quot;&gt;Case Study #2 - Pizza Runner&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-3/&quot;&gt;Case Study #3 - Foodie-Fi&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-4/&quot;&gt;Case Study #4 - Data Bank&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-5/&quot;&gt;Case Study #5 - Data Mart&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-6/&quot;&gt;Case Study #6 - Clique Bait&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-7/&quot;&gt;Case Study #7 - Balanced Tree Clothing Co.&lt;/a&gt;
    &lt;/li&gt;
  
    &lt;li&gt;
      &lt;a href=&quot;/case-study-8/&quot;&gt;Case Study #8 - Fresh Segments&lt;/a&gt;
    &lt;/li&gt;
  
&lt;/ul&gt;</content><author><name>Danny Ma</name></author><summary type="html"></summary><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/1.png" /><media:content medium="image" url="http://www.8weeksqlchallenge.com/%7B%7B%20site.baseurl%20%7D%7D/images/case-study-designs/1.png" xmlns:media="http://search.yahoo.com/mrss/" /></entry></feed>