This project focuses on analyzing COVID-19 data to gain insights into the impact of the pandemic. It includes SQL queries to retrieve and analyze data related to cases, deaths, vaccination rates, and more.
To run these queries, you need access to the PortfolioProject database. Make sure you have the necessary permissions to execute SQL queries.
This query retrieves the total cases and total deaths for each continent.
SELECT continent, Max(cast(Total_deaths as int)) as TotalDeathCount
FROM PortfolioProject..CovidDeaths
WHERE continent IS NOT NULL
GROUP BY continent
ORDER BY TotalDeathCount DESC
This query retrieves the total cases and total deaths for each country.
SELECT Location, Max(cast(Total_deaths as int)) as TotalDeathCount
FROM PortfolioProject..CovidDeaths
WHERE continent IS NOT NULL
GROUP BY Location
ORDER BY TotalDeathCount DESC
This query retrieves the total cases and total deaths in the United States.
SELECT Location, date, total_cases, total_deaths, (CAST(total_deaths AS float) / CAST(total_cases AS float)) * 100 AS DeathPercentage
FROM PortfolioProject..CovidDeaths
WHERE location LIKE '%states%' AND continent IS NOT NULL
ORDER BY Location, date
This query shows the percentage of the population that has been infected by COVID-19.
SELECT Location, date, total_cases, population, (CAST(total_cases AS float) / CAST(population AS float)) * 100 AS InfectionPercentage
FROM PortfolioProject..CovidDeaths
ORDER BY Location, date
This query identifies the countries with the highest infection rate relative to their population.
SELECT Location, population, Max(total_cases) as HighestInfectionCount, Max((CAST(total_cases AS float) / CAST(population AS float))) * 100 AS PercentagePopulationInfected
FROM PortfolioProject..CovidDeaths
GROUP BY Location, population
ORDER BY PercentagePopulationInfected DESC
This query shows the percentage of the population that has received at least one COVID-19 vaccine.
SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(CONVERT(int,vac.new_vaccinations)) OVER (PARTITION BY dea.Location ORDER BY dea.location, dea.Date) as RollingPeopleVaccinated
FROM PortfolioProject..CovidDeaths dea
JOIN PortfolioProject..CovidVaccinations vac
ON dea.location = vac.location
AND dea.date = vac.date
WHERE dea.continent IS NOT NULL
This view stores the data related to the percentage of the population that has been vaccinated against COVID-19. It includes the continent, location, date, population, new vaccinations, and rolling people vaccinated.
CREATE VIEW PercentPopulationVaccinated AS
SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations, SUM(CONVERT(int,vac.new_vaccinations)) OVER (PARTITION BY dea.Location ORDER BY dea.location, dea.Date) as RollingPeopleVaccinated
FROM PortfolioProject..CovidDeaths dea
JOIN PortfolioProject..CovidVaccinations vac
ON dea.location = vac.location
AND dea.date = vac.date
WHERE dea.continent IS NOT NULL
These queries and views provide valuable insights into the COVID-19 pandemic, including the total cases and deaths by continent and country, the infection rate relative to population, and the percentage of the population vaccinated. You can use this information to track the impact of the pandemic and make data-driven decisions.