Skip to content

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌍 World Layoffs — SQL Data Cleaning & Exploratory Analysis

An end-to-end MySQL data cleaning and exploratory analysis project that transforms raw global company layoffs data into an analysis-ready dataset and uses advanced SQL techniques to uncover trends across companies, industries, countries, and time.


📌 Project Overview

Real-world data rarely arrives analysis-ready.

This project starts with a raw dataset containing global company layoffs and builds a structured SQL workflow to:

  • Preserve raw data using staging tables
  • Detect and remove duplicate records
  • Standardize inconsistent values
  • Convert incorrect data types
  • Handle missing and NULL values
  • Prepare a clean dataset for analysis
  • Analyze layoffs across companies, industries, countries, and time
  • Calculate cumulative trends
  • Rank the companies with the highest layoffs each year

The project is divided into two phases:

Phase 1: Data Cleaning & Transformation Phase 2: Exploratory Data Analysis (EDA)


🔄 Project Workflow

Raw CSV Dataset
      ↓
MySQL Database
      ↓
Raw Data Table
      ↓
Staging Tables
      ↓
Data Cleaning & Standardization
      ↓
Missing Value Treatment
      ↓
Analysis-Ready Dataset
      ↓
Exploratory Data Analysis
      ↓
Trend Analysis & Company Rankings

🧹 Data Cleaning

The raw dataset was systematically prepared before analysis.

Duplicate Removal

Used ROW_NUMBER() with a window function to identify duplicate records across the dataset before removing them from the staging table.

Data Standardization

Standardized inconsistent categorical values including:

  • Company names and whitespace
  • Industry classifications
  • Country names
  • Other text attributes

For example, variations of the Crypto industry were consolidated into one standardized category.

Date Transformation

Converted the original text-based date field into the native MySQL DATE data type, enabling reliable time-series analysis.

Missing Value Handling

Converted empty strings into SQL NULL values and used a self join to recover missing industry information from other records belonging to the same company.

Unusable Records

Removed records where both primary layoff measures were missing and therefore provided insufficient analytical value.


🔍 Exploratory Data Analysis

After cleaning the dataset, SQL queries were developed to investigate several business questions.

Company Analysis

  • Companies with the highest cumulative layoffs
  • Largest individual layoff events
  • Companies reporting 100% workforce layoffs
  • Funding levels of companies that completely shut down

Industry Analysis

  • Industries experiencing the highest total layoffs
  • Comparison of workforce reductions across sectors

Geographic Analysis

  • Countries with the highest cumulative layoffs

Time-Series Analysis

  • Dataset start and end dates
  • Annual layoff totals
  • Monthly layoff trends
  • Cumulative layoffs over time

Company Ranking

Companies were aggregated by year and ranked using DENSE_RANK() to identify the Top 5 companies with the highest layoffs in each year.


🧠 Advanced SQL Techniques

This project demonstrates practical use of:

CTEsWindow FunctionsROW_NUMBER()DENSE_RANK()Self JoinsAggregationsGROUP BYDate FunctionsString FunctionsNULL HandlingData Type Conversion


🛠️ Technology

Database: MySQL Development Environment: MySQL Workbench Language: SQL


💼 Skills Demonstrated

  • SQL
  • MySQL
  • Data Cleaning
  • Data Transformation
  • Exploratory Data Analysis
  • Data Quality
  • Relational Data Operations
  • CTEs
  • Window Functions
  • Time-Series Analysis
  • Analytical Problem Solving

🚀 Future Enhancements

Potential extensions include:

  • Modularizing cleaning and analytical SQL scripts
  • Adding reusable SQL views
  • Implementing automated data-quality checks
  • Connecting the cleaned dataset to Power BI
  • Developing an interactive layoffs analytics dashboard

👤 Author

Muhammad Usman Ali MS Data Science | Data Analyst SQL • Power BI • Python • Excel • Data Modeling

About

Global layoffs data cleaning and exploratory analysis in MySQL, featuring staging tables, duplicate removal, data standardization, NULL handling, CTEs, window functions, rolling totals, and trend analysis.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors