Apr 6, 2025

MySQL Exploratory Data Analysis (EDA) on Layoffs Dataset

This SQL-based project explores the global layoffs landscape through the lens of structured data analysis. Using the cleaned version of the Layoffs dataset from the previous Data Cleaning Project, the goal was to identify significant patterns, trends, and outliers to understand the scope and nature of tech layoffs across companies, industries, and time. The analysis was performed using MySQL, and the full code can be found on GitHub.

Author

Tiany Sampilahy Heriniavo
Tiany Sampilahy Heriniavo

READ

5 mins
5 mins

Category

SQL
SQL
SQL
SQL
From Cleaned Data to Insights
From Cleaned Data to Insights

Following a detailed data cleaning phase from the previous Project, this exploratory analysis picks up with a ready-to-query staging table: layoffs_staging2. The aim was to generate descriptive insights that could help answer real-world questions, such as:

  • Which companies had the highest layoffs?

  • How widespread were layoffs across different countries and industries?

  • Were there notable peaks during specific months or years?

  • Did early-stage companies suffer more?

These insights are drawn purely from SQL queries, demonstrating the power of SQL in deriving analytical value from well-structured relational data.

SQL
SQL
Exploring Layoff Trends with SQL
Exploring Layoff Trends with SQL

Basic Exploration & Initial Metrics

We began by viewing the cleaned dataset:

SELECT * FROM

Then, we explored maximum values:

SELECT MAX(total_laid_off) FROM world_layoffs.layoffs_staging2;
SELECT MAX(percentage_laid_off), MIN(percentage_laid_off)
FROM world_layoffs.layoffs_staging2
WHERE percentage_laid_off IS NOT NULL

Detecting Extreme Layoffs

To find companies that laid off 100% of their workforce:

SELECT * FROM world_layoffs.layoffs_staging2
WHERE percentage_laid_off = 1

Ordering by their fundraising to highlight scale:

SELECT * FROM world_layoffs.layoffs_staging2
WHERE percentage_laid_off = 1
ORDER BY funds_raised_millions DESC

Largest Layoffs (Single Event & Cumulative)

Single largest layoffs:

SELECT company, total_laid_off
FROM world_layoffs.layoffs_staging2
ORDER BY total_laid_off DESC
LIMIT 5

Companies with the highest total layoffs:

SELECT company, SUM(total_laid_off)
FROM world_layoffs.layoffs_staging2
GROUP BY company
ORDER BY SUM(total_laid_off) DESC
LIMIT 10

Geographic Impact

By city and country:

SELECT location, SUM(total_laid_off)
FROM world_layoffs.layoffs_staging2
GROUP BY location
ORDER BY SUM(total_laid_off) DESC
LIMIT 10;

SELECT country, SUM(total_laid_off)
FROM world_layoffs.layoffs_staging2
GROUP BY country
ORDER BY SUM(total_laid_off) DESC

Time-Based Trends

Layoffs by year:

SELECT YEAR(date), SUM(total_laid_off)
FROM world_layoffs.layoffs_staging2
GROUP BY YEAR(date)
ORDER BY YEAR(date)

By industry and funding stage:

SELECT industry, SUM(total_laid_off)
FROM world_layoffs.layoffs_staging2
GROUP BY industry
ORDER BY SUM(total_laid_off) DESC;

SELECT stage, SUM(total_laid_off)
FROM world_layoffs.layoffs_staging2
GROUP BY stage
ORDER BY SUM(total_laid_off) DESC

Advanced Aggregations

Top companies per year by layoffs:

WITH Company_Year AS (
  SELECT company, YEAR(date) AS years, SUM(total_laid_off) AS total_laid_off
  FROM layoffs_staging2
  GROUP BY company, YEAR(date)
),
Company_Year_Rank AS (
  SELECT company, years, total_laid_off,
         DENSE_RANK() OVER (PARTITION BY years ORDER BY total_laid_off DESC) AS ranking
  FROM Company_Year
)
SELECT company, years, total_laid_off, ranking
FROM Company_Year_Rank
WHERE ranking <= 3 AND years IS NOT NULL
ORDER BY years, total_laid_off DESC

Rolling monthly layoffs:

WITH DATE_CTE AS (
  SELECT SUBSTRING(date,1,7) AS dates, SUM(total_laid_off) AS total_laid_off
  FROM layoffs_staging2
  GROUP BY dates
)
SELECT dates, SUM(total_laid_off) OVER (ORDER BY dates) AS rolling_total_layoffs
FROM DATE_CTE
ORDER BY

SQL
What the Data Tells Us About the Layoff Landscape
What the Data Tells Us About the Layoff Landscape

This analysis brought to light the scale and depth of layoffs in recent years. We found companies that laid off entire teams, regions most affected (with the U.S. standing out significantly), and periods when layoffs peaked. Industries like tech and crypto appeared disproportionately represented, especially among early-stage startups.

What made this project especially valuable was not just the numbers, but the story that emerged:

  • Some companies raised millions, only to fold months later.

  • A few firms repeatedly appeared at the top of layoff charts, signaling ongoing instability.

  • Layoffs surged in specific periods—often aligning with broader economic downturns or shifts in investment climates.

The next steps will include:

  • Data visualization: Transforming these insights into interactive dashboards with tools like Tableau or Power BI.

  • Predictive analysis: Exploring if layoffs can be forecasted based on funding stages or market trends.

  • Cross-dataset enrichment: Merging with stock performance, hiring data, or social sentiment for richer insights.


  • More Blogs More Blogs

03

//FAQ

Concerns

Frequently

Asked Questions

01

What services do you offer?

02

Do you work on both small and large projects?

03

What technologies do you use?

04

What do I need to get started?

05

How do you approach a new project?

06

How can I get in touch?

03

//FAQ

Concerns

Frequently

Asked Questions

01

What services do you offer?

02

Do you work on both small and large projects?

03

What technologies do you use?

04

What do I need to get started?

05

How do you approach a new project?

06

How can I get in touch?

//FAQ

Concerns

Frequently

Asked Question

What services do you offer?
Do you work on both small and large projects?
What technologies do you use?
What do I need to get started?
How do you approach a new project?
How can I get in touch?

03

//FAQ

Concerns

Frequently

Asked Questions

01

What services do you offer?

02

Do you work on both small and large projects?

03

What technologies do you use?

04

What do I need to get started?

05

How do you approach a new project?

06

How can I get in touch?

Let'S WORK

TOGETHER

BASED IN Antananarivo,

madagascar

Fullstack developer

+ Entrepreneur

Have a project in mind or just want to connect? Let’s build something amazing together!

Let'S WORK

TOGETHER

BASED IN Antananarivo,

madagascar

Fullstack developer

+ Entrepreneur

Have a project in mind or just want to connect? Let’s build something amazing together!

Let'S WORK

TOGETHER

BASED IN USA, I AM AN INNOVATIVE DESIGNER AND DIGITAL ARTIST. MY PASSION FOR MINIMALIST AESTHETICS, ELEGANT TYPOGRAPHY, AND INTUITIVE DESIGN IS EVIDENT IN MY WORK.

Let'S WORK

TOGETHER

BASED IN Antananarivo,

madagascar

Fullstack developer

+ Entrepreneur

BASED IN USA, I AM AN INNOVATIVE DESIGNER AND DIGITAL ARTIST. MY PASSION FOR MINIMALIST AESTHETICS, ELEGANT TYPOGRAPHY, AND INTUITIVE DESIGN IS EVIDENT IN MY WORK.

Create a free website with Framer, the website builder loved by startups, designers and agencies.