Skip to content

Commit

Permalink
Update COVID Dashboard Project
Browse files Browse the repository at this point in the history
  • Loading branch information
oTheAnalyst authored Apr 15, 2022
1 parent d222a3e commit 4d72f46
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions COVID Dashboard Project
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*

Covid 19 Data Exploration
Skills used: Joins, CTE's, Temp Tables, Windows Functions, Aggregate Functions, Creating Views, Converting Data Types
*/
Expand All @@ -9,7 +10,6 @@ Where continent is not null
order by 3,4


-- Select Data that we are going to be starting with

Select Location, date, total_cases, new_cases, total_deaths, population
From PortfolioProject..CovidDeaths
Expand All @@ -27,16 +27,15 @@ and continent is not null
order by 1,2


-- Total Cases vs Population
-- Shows what percentage of population infected with Covid


Select Location, date, Population, total_cases, (total_cases/population)*100 as PercentPopulationInfected
From PortfolioProject..CovidDeaths
--Where location like '%states%'
order by 1,2


-- Countries with Highest Infection Rate compared to Population


Select Location, Population, MAX(total_cases) as HighestInfectionCount, Max((total_cases/population))*100 as PercentPopulationInfected
From PortfolioProject..CovidDeaths
Expand All @@ -45,7 +44,7 @@ Group by Location, Population
order by PercentPopulationInfected desc


-- Countries with Highest Death Count per Population


Select Location, MAX(cast(Total_deaths as int)) as TotalDeathCount
From PortfolioProject..CovidDeaths
Expand All @@ -56,7 +55,6 @@ order by TotalDeathCount desc



-- BREAKING THINGS DOWN BY CONTINENT


Select continent, MAX(cast(Total_deaths as int)) as TotalDeathCount
Expand All @@ -68,7 +66,6 @@ order by TotalDeathCount desc



-- GLOBAL NUMBERS

Select SUM(new_cases) as total_cases, SUM(cast(new_deaths as int)) as total_deaths, SUM(cast(new_deaths as int))/SUM(New_Cases)*100 as DeathPercentage
From PortfolioProject..CovidDeaths
Expand All @@ -79,7 +76,6 @@ order by 1,2



-- Total Population vs Vaccinations


Select dea.continent, dea.location, dea.date, dea.population, vac.new_vaccinations
Expand All @@ -93,7 +89,7 @@ where dea.continent is not null
order by 2,3


-- Using CTE to perform Calculation on Partition By in previous query


With PopvsVac (Continent, Location, Date, Population, New_Vaccinations, RollingPeopleVaccinated)
as
Expand All @@ -113,7 +109,7 @@ From PopvsVac



-- Using Temp Table to perform Calculation on Partition By in previous query


DROP Table if exists #PercentPopulationVaccinated
Create Table #PercentPopulationVaccinated
Expand All @@ -134,17 +130,13 @@ From PortfolioProject..CovidDeaths dea
Join PortfolioProject..CovidVaccinations vac
On dea.location = vac.location
and dea.date = vac.date
--where dea.continent is not null
--order by 2,3


Select *, (RollingPeopleVaccinated/Population)*100
From #PercentPopulationVaccinated




-- Creating View to store data for later visualizations

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
Expand Down

0 comments on commit 4d72f46

Please sign in to comment.