Target SQL - Reference
Target SQL - Reference
❖ Topic: SQL
❖ Duration: 1 week
____________________________________________________________________________
Features Description
customer_state State Code from where order is made (Eg. são paulo - SP)
Features Description
geolocation_lat Latitude
geolocation_lng Longitude
geolocation_city City
geolocation_state State
The sellers.csv contains following features:
Features Description
Unique ID of the seller registered
seller_id
Features Description
Features Description
Features Description
Features Description
Features Description
Dataset schema:
____________________________________________________________________________
To complete the case study, begin by downloading the CSV files from the provided link.
Afterward, proceed to upload them onto BigQuery for further analysis.
Assuming you have already established a project called "Ecommerce" in your SQL workspace,
the next step is to create a new dataset named "target."
Now, systematically upload each CSV file as a separate BigQuery table within the "target"
dataset.
Once all the files have been successfully uploaded, you can conveniently access them within
the query editor by referencing the dataset and table names.
For example,
● To access the "customers" table, you would use the reference `target.customers`.
● Similarly, for the "orders" table, you would use `target.orders`, and so on.
____________________________________________________________________________
What is expected?
Assuming you are a data analyst/ scientist at Target, you have been assigned the task of
analyzing the given dataset to extract valuable insights and provide actionable
recommendations.
Submission Process:
Once you’re done with the case study...
● Use a Word document to paste your SQL queries along with a screenshot of the first
10 rows from the output.
● List down any valuable insights that you find during the analysis and provide some
action items from the company’s perspective in order to improve the current situation.
● Convert your solutions doc into a PDF, and upload the same on the platform.
● Please note that after submitting once, you will not be allowed to edit your submission.
General Guidelines:
Evaluation will be kept lenient, so make sure you attempt this case study.
●
It is understandable that you might struggle with getting started on this or feel stuck at
●
some point.
In such case:
a. Read the question carefully and try to understand what exactly is being asked.
b. Brainstorm a little. If you’re getting an error, remember that Google is your best
friend.
c. You can watch the lecture recordings or go through your lecture notes once
again if you feel like you’re getting confused over some specific topics.
d. Discuss your problems with your peers. Make use of the Slack channel and
WhatsApp group.
e. Only if you think that there’s a major issue, you can reach out to your Instructor
via Slack or Email.
____________________________________________________________________________
I. Import the dataset and do usual exploratory analysis steps like checking the
structure & characteristics of the dataset.
A. Data type of all columns in the “customers” table.
Hint: We want you to display the data type of each column present in the
“customers” table.
B. Get the time range between which the orders were placed.
Hint: We want you to get the date & time when the first and last orders in our
dataset were placed.
C. Count the Cities & States of customers who ordered during the given period.
Hint: We want you to count the number of unique cities & states where orders
were placed by the customers during the given time period.
______________________________________________________________________________
Hint: We want you to find out if no. of orders placed has increased gradually in
each month, over the past years.
B. Can we see some kind of monthly seasonality in terms of the no. of orders being
placed?
Hint: We want you to find out if the no. of orders placed are at peak during
certain months.
C. During what time of the day, do the Brazilian customers mostly place their
orders? (Dawn, Morning, Afternoon or Night)
● 0-6 hrs : Dawn
● 7-12 hrs : Mornings
● 13-18 hrs : Afternoon
● 19-23 hrs : Night
Hint: We want you to categorize the hours of a day into the given time brackets/
intervals and find out during which intervals the Brazilian customers usually
order the most.
______________________________________________________________________________
Hint: We want you to get the no. of orders placed in each state, in each month
by our customers.
Hint: You can use the payment_value column in the payments table to get the
cost of orders.
B. Calculate the Total & Average value of order price for each state.
Hint: We want you to fetch the total price and the average price of orders for
each state.
C. Calculate the Total & Average value of order freight for each state.
Hint: We want you to fetch the total freight value and the average freight value
of orders for each state.
_____________________________________________________________________________________
Hint: You can calculate the delivery time and the difference between the
estimated & actual delivery date using the given formula:
● time_to_deliver = order_delivered_customer_date -
order_purchase_timestamp
● diff_estimated_delivery = order_estimated_delivery_date -
order_delivered_customer_date
B. Find out the top 5 states with the highest & lowest average freight value.
Hint: We want you to find the top 5 & the bottom 5 states arranged in
increasing order of the average freight value.
C. Find out the top 5 states with the highest & lowest average delivery time.
Hint: We want you to find the top 5 & the bottom 5 states arranged in
increasing order of the average delivery time.
D. Find out the top 5 states where the order delivery is really fast as compared to
the estimated date of delivery.
You can use the difference between the averages of actual & estimated delivery
date to figure out how fast the delivery was for each state.
Hint: We want you to count the no. of orders placed using different payment
methods in each month over the past years.
B. Find the no. of orders placed on the basis of the payment installments that have
been paid.
Hint: We want you to count the no. of orders placed based on the no. of
payment installments where at least one installment has been successfully
paid.
____________________________________________________________________________
FAQs
Q. Which platform am I supposed to use for writing queries?
You are advised to use BigQuery as the platform for solving this case study.