Skip to content

This is a practice dataset designed to help master the SELECT and WHERE statements in SQL using real life scenarios.

Notifications You must be signed in to change notification settings

Lily-16-ui/SQL_ORDERS_PROJECT

Repository files navigation

SQL Orders Management Project

Mastering SELECT and WHERE Statements Through a Real-World Scenario

Table of contents

Project Overview

This project simulates a small business tracking customer orders. I tracked the order flow for a company using only SELECT and WHERE statements to practice applying theory to real-world tasks.

Screenshot 2025-12-08 020058

The goal was:

  • Build confidence writing SQL independently
  • Learn how to think like an analyst
  • Practice data cleaning and querying with limited tools.
  • Use simple SQL to answer “client-style” questions.

What I Practiced

This project helped me master:

  • Creating tables using CREATE TABLE
  • Inserting values using INSERT INTO
  • Cleaning inconsistent entries using only SELECT + WHERE
  • Using REPLACE, CASE, and filtering logic
  • Handling NULL values
  • Writing queries to answer business questions.
  • Calculating date differences with DATEDIFF

Database Structure

The ORDERS table contains: Order_id, price, status, item, delivery_city, customer_name, order_date, delivery_date.

Screenshot 2025-12-08 025822

Data Cleaning Tasks

All cleaning was done using SELECT + WHERE only. I Cleaned:

  • Inconsistent city names (lagos, Lagos, ABUJA, abj)

  • Status variations (Pending, pending, Delivered, delivered)

  • NULL values in amount and delivery date

  • Conditional replacements using CASE Example cleaning snippet: SELECT order_id, item, status, delivery_city, customer_name, price, order_date, delivery_date,

    CASE WHEN LOWER(delivery_city) = 'lagos' THEN 'Lagos' WHEN LOWER(delivery_city) IN ('abuja', 'abj') THEN 'Abuja' ELSE delivery_city END AS cleaned_city, CASE WHEN LOWER(status) = 'delivered' THEN 'Delivered' WHEN LOWER(status) = 'pending' THEN 'Pending' ELSE status END AS cleaned_status, REPLACE(item, '_', ' ') AS cleaned_item FROM orders;

Screenshot 2025-12-08 020200

Client Questions Answered

Some of the business questions solved:

Q1: Find all orders delivered late (delivery took more than 4 days).

Q2: Find all orders that were not delivered (delivery date is NULL).

Q3: List all orders from Lagos (case-insensitive).

Q4: Find all orders where the price is missing or not a valid number.

Q5: Retrieve all orders for “Power Bank” items (take note of inconsistent naming).

Example query: SELECT * FROM [dbo].[ORDERS] WHERE DATEDIFF(DAY, order_date, delivery_date) > 4;

Screenshot 2025-12-08 030155

Key Learnings

  • SQL is easier when approached with real-life scenarios.
  • SELECT + WHERE alone can solve a surprising number of problems.
  • Small projects build confidence faster than long tutorials

About

This is a practice dataset designed to help master the SELECT and WHERE statements in SQL using real life scenarios.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published