GL SQL Project
Project report
Rohan Mohan
27/7/2025
Table of Contents
Context..................................................................................................................................................2
Objective...............................................................................................................................................2
Dataset highlights..................................................................................................................................2
ER Diagram............................................................................................................................................4
Question 1: Find the total number of customers who have placed orders. What is the distribution of
the customers across states?.................................................................................................................5
Question 2: Which are the top 5 vehicle makers preferred by the customers?.....................................7
Question 3: Which is the most preferred vehicle maker in each state?.................................................8
Question 4: Find the overall average rating given by the customers. What is the average rating in each
quarter?...............................................................................................................................................10
Question 5: Find the percentage distribution of feedback from the customers. Are customers getting
more dissatisfied over time?...............................................................................................................12
Question 6: What is the trend of the number of orders by quarter?...................................................14
Question 7: Calculate the net revenue generated by the company. What is the quarter-over-quarter
% change in net revenue?....................................................................................................................15
Question 8: What is the trend of net revenue and orders by quarters?..............................................16
Question 9: What is the average discount offered for different types of credit cards?........................17
Question 10: What is the average time taken to ship the placed orders for each quarter?.................18
Business Metrics Overview..................................................................................................................19
Business Recommendations................................................................................................................19
Insights and recommendations........................................................................................................20
1
Context
A lot of people in the world share a common desire: to own a vehicle. A car or an automobile is seen
as an object that gives the freedom of mobility. Many now prefer pre-owned vehicles because they
come at an affordable cost, but at the same time, they are also concerned about whether the after-
sales service provided by the resale vendors is as good as the care you may get from the actual
manufacturers. New-Wheels, a vehicle resale company, has launched an app with an end-to-end
service from listing the vehicle on the platform to shipping it to the customer's location. This app also
captures the overall after-sales feedback given by the customer.
Objective
New-Wheels sales have been dipping steadily in the past year, and due to the critical customer
feedback and ratings online, there has been a drop in new customers every quarter, which is
concerning to the business. The CEO of the company now wants a quarterly report with all the
key metrics sent to him so he can assess the health of the business and make the necessary
decisions.
As a data analyst, you see that there is an array of questions that are being asked at the
leadership level that need to be answered using data. Import the dump file that contains various
tables that are present in the database. Use the data to answer the questions posed and create a
quarterly business report for the CEO
Dataset highlights
The data provided has
Attributes on the vehicles New-Wheels sells - What are the make, model, and year? What is the
price point?
Attributes on the customers, such as where they live and payment methods
Attributes on orders and shipments, such as when the order was shipped and received, what the
after-sales feedback was, and so on
New Wheels Data Dictionary
shipper_id: Unique ID of the Shipper
shipper_name: Name of the Shipper
shipper_contact_details: Contact detail of the Shipper
product_id: Unique ID of the Product
vehicle_maker: Vehicle Manufacturing company name
vehicle_model: Vehicle model name
vehicle_color: Color of the Vehicle
vehicle_model_year: Year of Manufacturing
vehicle_price: Price of the Vehicle
2
quantity: Ordered Quantity
customer_id: Unique ID of the customer
customer_name: Name of the customer
gender: Gender of the customer
job_title: Job Title of the customer
phone_number: Contact detail of the customer
email_address: Email address of the customer
city: Residing city of the customer
country: Residing country of the customer
state: Residing state of the customer
customer_address: Address of the customer
order_date: Date on which customer ordered the vehicle
order_id: Unique ID of the order
ship_date: Shipment Date
ship_mode: Shipping Mode/Class
shipping: Shipping Ways
postal_code: Postal Code of the customer
discount: Discount given to the customer for the particular order by credit card in percentage
credit_card_type: Credit Card Type
credit_card_number: Credit card number
customer_feedback: Feedback of the customer
quarter_number : Quarter Number
ER Diagram
3
4
Question 1: Find the total number of
customers who have placed orders. What is
the distribution of the customers across
states?
Query 1
Select count(distinct(customer_id)) as dist_cust
from order_t
Query 2
Select state, count(customer_id) as cust
from customer_t
group by state
order by cust desc
Output1:
5
Output2:
Observations and Insights:
● There are 994 distinct customers who have
placed orders
● The distribution of customers is across 49 states
● 384 customers reside in the top 4 states itself
● Texas and California have the highest number of
customers (97 each) followed by florida (86) and
New York (69)
6
Question 2: Which are the top 5 vehicle
makers preferred by the customers?
Solution Query:
SELECT
vehicle_maker,
COUNT(customer_t.customer_id) AS cust
FROM
product_t JOIN order_t ON product_t.product_id = order_t.product_id
JOIN
customer_t ON order_t.customer_id = customer_t.customer_id
GROUP BY vehicle_maker
ORDER BY cust DESC
LIMIT 5;
Output:
7
Observations and Insights:
● Top 5 vehicle makers preferred by customers in order of preference are
Chevrolet (83), Ford (63), Toyota (52), Pontiac (50) and Dodge (50)
8
Question 3: Which is the most preferred
vehicle maker in each state?
Solution Query:
SELECT *
FROM
SELECT
state,
vehicle_maker,
COUNT(customer_id) AS total_customers,
RANK() OVER (PARTITION BY state ORDER BY COUNT(customer_id) DESC) AS
ranking
FROM product_t
JOIN order_t USING(product_id)
JOIN customer_t USING(customer_id)
GROUP BY 1, 2
) AS preferred_vehicle
WHERE ranking = 1
ORDER BY 3 DESC;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
9
10
Question 4: Find the overall average rating
given by the customers. What is the average
rating in each quarter?
Consider the following mapping for ratings: “Very Bad”: 1, “Bad”: 2, “Okay”: 3, “Good”: 4, “Very
Good”: 5
Solution Query:
WITH rating AS
SELECT
customer_feedback,
quarter_number,
CASE
WHEN customer_feedback = 'very bad' THEN '1'
WHEN customer_feedback = 'bad' THEN '2'
WHEN customer_feedback = 'okay' THEN '3'
WHEN customer_feedback = 'good' THEN '4'
WHEN customer_feedback = 'very good' THEN '5'
END AS total_rating
FROM order_t
SELECT
quarter_number,
ROUND(AVG(total_rating), 2) AS average_rating
FROM rating
GROUP BY 1
ORDER BY 1 ASC;
Output:
11
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
●
●
●
12
Question 5: Find the percentage distribution
of feedback from the customers. Are
customers getting more dissatisfied over
time?
Solution Query:
WITH cust_feed AS
SELECT
quarter_number,
ROUND(SUM(CASE WHEN customer_feedback = 'very good' THEN 1
ELSE 0 END), 2) AS very_good,
ROUND(SUM(CASE WHEN customer_feedback = 'good' THEN 1 ELSE
0 END), 2) AS good,
ROUND(SUM(CASE WHEN customer_feedback = 'okay' THEN 1 ELSE
0 END), 2) AS okay,
ROUND(SUM(CASE WHEN customer_feedback = 'bad' THEN 1 ELSE
0 END), 2) AS bad,
ROUND(SUM(CASE WHEN customer_feedback = 'very bad' THEN 1
ELSE 0 END), 2) AS very_bad,
ROUND(COUNT(customer_feedback), 2) AS total_feedback
FROM order_t
GROUP BY 1
ORDER BY 1 ASC
SELECT
quarter_number,
ROUND((very_good/total_feedback), 2) AS very_good,
ROUND((good/total_feedback), 2) AS good,
ROUND((okay/total_feedback), 2) AS okay,
13
ROUND((bad/total_feedback), 2) AS bad,
ROUND((very_bad/total_feedback), 2) AS very_bad
FROM cust_feed
GROUP BY 1
ORDER BY 1 ASC;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
●
●
●
14
Question 6: What is the trend of the number
of orders by quarter?
Solution Query:
SELECT
quarter_number,
COUNT(order_id) AS total_orders
FROM order_t
GROUP BY 1
ORDER BY 1;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
●
●
●
15
Question 7: Calculate the net revenue
generated by the company. What is the
quarter-over-quarter % change in net
revenue?
Solution Query:
WITH QoQ AS
SELECT quarter_number,
ROUND(SUM(quantity * (vehicle_price - ((discount/100)*vehicle_price))), 0)
AS revenue
FROM order_t
GROUP BY quarter_number)
SELECT quarter_number, revenue,
ROUND(LAG(revenue) OVER(ORDER BY quarter_number), 2) AS
previous_revenue,
ROUND((revenue - LAG(revenue) OVER(ORDER BY
quarter_number))/LAG(revenue) OVER(ORDER BY quarter_number), 2) AS
qoq_perc_change
FROM QoQ;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
●
●
●
16
Question 8: What is the trend of net revenue
and orders by quarters?
Solution Query:
SELECT
quarter_number,
ROUND(SUM(quantity*vehicle_price), 0) AS revenue,
COUNT(order_id) AS total_order
FROM order_t
GROUP BY 1
ORDER BY 1;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
●
●
●
17
Question 9: What is the average discount
offered for different types of credit cards?
Solution Query:
SELECT
credit_card_type,
ROUND(AVG(discount), 2) AS average_discount
FROM order_t t1
INNER JOIN customer_t t2
ON t1.customer_id = t2.customer_id
GROUP BY 1
ORDER BY 2 DESC;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
Observations and Insights:
●
●
●
18
Question 10: What is the average time taken
to ship the placed orders for each quarter?
Solution Query:
SELECT
quarter_number,
ROUND(AVG(DATEDIFF(ship_date, order_date)), 0) AS average_shipping_time
FROM order_t
GROUP BY 1
ORDER BY 1;
Output:
<Attach the screenshot of your output table>
● The screenshot should display 5-10 rows of the output
● Make sure the screenshot contains the “SQL Query Passed” along with the
output table.
19
Business Metrics Overview
Total Revenue Total Orders Total Customers Average Rating
<enter_value> <enter_value> <enter_value> <enter_value>
Last Quarter Last quarter Orders Average Days to % Good Feedback
Revenue Ship
<enter_value> <enter_value> <enter_value> <enter_value>
Business Recommendations
●
●
●
1.
20
Insights and recommendations
1.
21