SQL Project Series Food & Grocery Delivery Analytics ๐Ÿ›’ Analyzeโ€ฆ โ€” Programming Bay โ€” TG.ME

๐Ÿš€ SQL Project Series

Food & Grocery Delivery Analytics ๐Ÿ›’

Analyze customers, stores, products, orders, deliveries, and payments to understand sales performance, customer behavior, delivery efficiency, and operational costs.

๐ŸŽฏ Business Objectives

โœ… Analyze order and revenue trends

โœ… Identify top-selling products

โœ… Measure customer retention

โœ… Analyze store performance

โœ… Track delivery efficiency

โœ… Identify peak ordering periods

โœ… Monitor cancellations and refunds

โœ… Optimize product and store performance

๐Ÿ“‚ Database Setup

CREATE DATABASE grocery_delivery_db;
USE grocery_delivery_db;


Tables Created:

customers โ†’ customer_id, customer_name, city, signup_date

stores โ†’ store_id, store_name, city, store_type

products โ†’ product_id, product_name, category, price

orders โ†’ order_id, customer_id, store_id, order_date, order_status, delivery_time_minutes, delivery_fee

order_items โ†’ order_item_id, order_id, product_id, quantity, unit_price

Sample data for 5 customers, 4 stores, 5 products, 5 orders already included.

๐Ÿง  SQL Concepts You'll Practice

โœ” INNER JOIN, LEFT JOIN

โœ” Aggregate Functions, GROUP BY, HAVING

โœ” CASE WHEN, CTEs, Subqueries

โœ” Window Functions

โœ” Date & Time Functions

โœ” Conditional Aggregation

๐Ÿ“Š Business KPIs You Can Build

๐Ÿ“ˆ Total Orders, Completed Orders, Cancelled Orders, Cancellation Rate

๐Ÿ“ˆ Total Revenue, AOV, Average Basket Size, Items Sold

๐Ÿ“ˆ Revenue by Category, Store, City

๐Ÿ“ˆ Top-Selling / Low-Selling Products

๐Ÿ“ˆ Customer Lifetime Value, Repeat Purchase Rate, Retention Rate

๐Ÿ“ˆ Average Delivery Time, On-Time Delivery Rate

๐Ÿ“ˆ Peak Ordering Hour, Peak Ordering Day, Monthly Revenue Growth

๐Ÿ“ˆ Delivery Fee Revenue, Customer Acquisition Trend

๐Ÿ“ˆ Executive Grocery Delivery Dashboard

๐Ÿ’ก Example Queries

1. Total Revenue

SELECT SUM(oi.quantity * oi.unit_price) AS total_revenue
FROM orders o
JOIN order_items oi ON o.order_id = oi.order_id
WHERE o.order_status = 'Delivered';


2. Top-Selling Products

SELECT p.product_name, SUM(oi.quantity) AS units_sold
FROM products p
JOIN order_items oi ON p.product_id = oi.product_id
JOIN orders o ON oi.order_id = o.order_id
WHERE o.order_status = 'Delivered'
GROUP BY p.product_name
ORDER BY units_sold DESC
LIMIT 10;


3. Average Order Value

WITH order_values AS (
SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS order_value
FROM orders o
JOIN order_items oi ON o.order_id = oi.order_id
WHERE o.order_status = 'Delivered'
GROUP BY o.order_id
)
SELECT ROUND(AVG(order_value), 2) AS average_order_value FROM order_values;


4. Repeat Customers

SELECT customer_id, COUNT(order_id) AS total_orders
FROM orders
WHERE order_status = 'Delivered'
GROUP BY customer_id
HAVING COUNT(order_id) > 1;


5. Revenue by Store

SELECT s.store_name, SUM(oi.quantity * oi.unit_price) AS revenue
FROM stores s
JOIN orders o ON s.store_id = o.store_id
JOIN order_items oi ON o.order_id = oi.order_id
WHERE o.order_status = 'Delivered'
GROUP BY s.store_name
ORDER BY revenue DESC;


6. Cancellation Rate

SELECT ROUND(100.0 * SUM(CASE WHEN order_status = 'Cancelled' THEN 1 ELSE 0 END) / COUNT(*), 2) AS cancellation_rate
FROM orders;


7. Peak Ordering Hours

SELECT EXTRACT(HOUR FROM order_date) AS order_hour, COUNT(*) AS total_orders
FROM orders
WHERE order_status = 'Delivered'
GROUP BY EXTRACT(HOUR FROM order_date)
ORDER BY total_orders DESC;


Claim your Free $5 Bonus Here:
https://bit.ly/3wUxw09

Join our WhatsApp Channel ๐Ÿ‘‡

https://whatsapp.com/channel/0029VbAi27y0lwghBe9mE42i

WhatsApp Community Link ๐Ÿ‘‡

https://chat.whatsapp.com/HPJDqRr6G1sKQIqfdJF3pL

1๏ธโƒฃ GROUP FOR PROGRAMMERS๐Ÿ–ฅ
๐Ÿ“Ž Channel Link:
[ https://t.me/realgroupforprogrammer ]

---

2๏ธโƒฃ Coding Community
๐Ÿ“Ž Channel Link:
[ https://t.me/Coding_CommunityOfficial ]

---

3๏ธโƒฃ Programming Bay
๐Ÿ“Ž Channel Link:
[ https://t.me/programmingbay ]

---

4๏ธโƒฃ Data Structures and Algorithms
๐Ÿ“Ž Channel Link:
[ https://t.me/datastructuresandalgoofficial ]

Share with your College Whatsapp Groups & Friends too
August 15, 2026 191 10