This project, is based on Alex Freberg’s Portoflio Project Series where we do basic data exploration in SQL.
Code
--Select Data that we are going to be using SELECT location,date, total_cases, new_cases, total_deaths, populationFROM Covid..CovidDeathsORDERBY1,2-- Looking at Total Cases v. Total Deaths (daily death rate) in the United StatesSELECT location,date, total_cases, total_deaths, (total_deaths / total_cases) *100AS death_percentageFROM Covid..CovidDeathsWhere location like'%state%'ORDERBY1,2-- Looking at Total Cases v. Population -- Percent of population were infectedSELECT location,date, total_cases, population, (total_cases / population) *100AS infected_percentageFROM Covid..CovidDeathsWhere location like'%state%'ORDERBY1,2-- Looking at countries with highest infection rate compared to population SELECT location,MAX(total_cases) AS highest_infection_count, population, (MAX(total_cases) / population) *100AS infected_percentageFROM Covid..CovidDeathsGROUPBY location, populationORDERBY infected_percentage DESC-- Showing countries with the highest death count per population SELECT location,MAX(total_deaths) AS total_death_countFROM Covid..CovidDeathsWHERE continent ISNOTNULLGROUPBY locationORDERBY total_death_count DESC-- Showing the contients with the highest death counts SELECT location,MAX(total_deaths) AS total_death_countFROM Covid..CovidDeathsWHERE continent ISNULLGROUPBY locationORDERBY total_death_count DESC-- Global NumbersSELECTdate,SUM(new_cases) AS new_case_count,SUM(new_deaths) AS new_death_cout, (SUM(new_deaths) /SUM(new_cases)) *100AS global_death_percentageFROM Covid..CovidDeathsWHERE continent ISNOTNULLGROUPBYdateORDERBY1,2-- Total Cases v. Total Deaths (Globally)SELECTSUM(new_cases) AS new_case_count,SUM(new_deaths) AS new_death_cout, (SUM(new_deaths) /SUM(new_cases)) *100AS global_death_percentageFROM Covid..CovidDeathsWHERE continent ISNOTNULL-- Looking at Total Population v. VaccinationsWITH PopvVac (Continent, Location, Date, Population, New_Vaccination, Rolling_Total_Vaccination)AS(SELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations,SUM(vac.new_vaccinations) OVER (PARTITIONBY dea.location ORDERBY dea.location, dea.date) AS rolling_total_vaccination FROM Covid..CovidDeaths dea Join Covid..CovidVaccinations vacON dea.location = vac.location and dea.date= vac.dateWHERE dea.continent ISNOTNULL)SELECT*, (Rolling_Total_Vaccination / Population) *100AS Rolling_Vaccination_PercentageFROM PopvVac-- Creating View to store data for later visualization CREATEVIEW PopvVac ASSELECT dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations,SUM(vac.new_vaccinations) OVER (PARTITIONBY dea.location ORDERBY dea.location, dea.date) AS rolling_total_vaccination FROM Covid..CovidDeaths dea Join Covid..CovidVaccinations vacON dea.location = vac.location and dea.date= vac.dateWHERE dea.continent ISNOTNULL