🧠 Project Motivation

Layoffs have been a critical global issue, especially during times of economic uncertainty. I wanted to dive deep into a real-world dataset to explore the dynamics behind massive layoffs across industries, countries, and funding stages.

This project allowed me to strengthen my SQL skills through practical analysis, while also gaining insights into company behaviour and market responses during turbulent times.

Explaratory Data Analysis on Layoffs Data

This project involved analysing layoff trends using SQL to explore how industries, countries, and funding stages were impacted during global economic shifts. A comprehensive exploratory data analysis was conducted on a public dataset, using various SQL techniques and queries to extract meaningful insights.

🎯 Objectives

🛠️ Techniques Used

💻 Sample SQL Queries

Monthly Rolling Total of Layoffs


WITH rolling_total AS (
    SELECT SUBSTRING(`date`, 1, 7) AS `month`,
           SUM(total_laid_off) AS total_off
    FROM layoffs_staging2
    WHERE SUBSTRING(`date`, 1, 7) IS NOT NULL
    GROUP BY `month`
)
SELECT `month`, total_off,
       SUM(total_off) OVER(ORDER BY `month`) AS rolling_total;
                

Top 5 companies with the highest layoffs per year


WITH company_year(company, year, total_laid_off) AS (
    SELECT company, YEAR(`date`), SUM(total_laid_off)
    FROM layoffs_staging2
    GROUP BY company, YEAR(`date`)
),
company_year_ranked AS (
    SELECT *, DENSE_RANK() OVER(PARTITION BY year ORDER BY total_laid_off DESC) AS ranking
    FROM company_year
)
SELECT *
FROM company_year_ranked
WHERE ranking <= 5;
                

Industries with total layoffs exceeding 10000


SELECT industry, 
       SUM(total_laid_off) AS total_layoffs, 
       SUM(funds_raised_millions) AS total_funding
FROM layoffs_staging2
GROUP BY industry
HAVING SUM(total_laid_off) > 10000
ORDER BY total_funding DESC;
                

Year-based Post-IPO industry analysis


WITH top_industry_yearly AS (
    SELECT
        YEAR(`date`) AS year,
        industry,
        SUM(total_laid_off) AS total_layoff,
        ROW_NUMBER() OVER(PARTITION BY YEAR(`date`) ORDER BY SUM(total_laid_off) DESC) AS ranked_industries
    FROM layoffs_staging2
    WHERE stage = 'Post-IPO'
    GROUP BY year, industry
),
top_company_in_industry AS (
    SELECT
        YEAR(`date`) AS year,
        industry,
        company,
        SUM(total_laid_off) AS company_layoff
    FROM layoffs_staging2
    GROUP BY YEAR(`date`), industry, company
)
SELECT
    t1.year,
    t1.industry,
    t2.company,
    t2.company_layoff
FROM top_industry_yearly t1
JOIN top_company_in_industry t2
    ON t1.year = t2.year AND t1.industry = t2.industry
WHERE t1.ranked_industries = 1
ORDER BY t1.year, t2.company_layoff DESC;
                

📊 Key Insights

📊 Interactive Tableau Dashboard

← Back to Home