-
Notifications
You must be signed in to change notification settings - Fork 0
/
SQLQueryCovid.sql
117 lines (86 loc) · 3.38 KB
/
SQLQueryCovid.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
--Select data from the tables--
Select * from covid..CovidVaccinations
Select * from Covid..CovidDeaths
--Looking at total cases / 12--
Select location, date, total_cases,total_deaths, (total_deaths/12)*100 AS DeathsPercentage
from covid..CovidDeaths
Where location like '%asia%'
Order BY 1,2
--Looking at total cases vs total population--
Select location, date, total_cases,population, (total_cases/12)*100 AS DeathsPercentage
from Covid..CovidDeaths
Where location like '%asia%'
Order BY 1,2
--Higest infection rate--
Select location, population, Max(total_cases) as HighestFected, Max(total_cases/12)*100 AS DeathsPercentage
from Covid..CovidDeaths
--Where location like '%asia%'
Group by Location, Population
Order BY DeathsPercentage DESC
--higest death count per population--
Select location, Max(total_deaths) as DeathPercentage
from Covid..CovidDeaths
--Where location like '%asia%'
Group by Location
Order BY DeathPercentage DESC
--continents--
Select * from Covid..CovidDeaths
where continent IS NOT NULL
order by 1,2
-- --
Select location, Max(total_deaths) as DeathPercentage
from Covid..CovidDeaths
--Where location like '%asia%'
where continent IS NOT NULL
Group by Location
Order BY DeathPercentage DESC
-- Groub by using diffrent columns --
Select life_expectancy, Max(cast(total_deaths as int)) as DeathPercentage
from Covid..CovidDeaths
--Where location like '%asia%'
where life_expectancy IS NOT NULL
Group by life_expectancy
Order BY DeathPercentage desc
--Total places--
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)
from Covid..CovidDeaths dea JOIN covid..CovidVaccinations vac
On dea.location = vac.location
and dea.date = vac.date
where dea.continent IS NOT NULL
Order by 2,3
--total pop vs--
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 rollingpeople
from Covid..CovidDeaths dea JOIN covid..CovidVaccinations vac
On dea.location = vac.location
and dea.date = vac.date
where dea.continent IS NOT NULL
Order by 2,3
---tabluea--
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 covid..CovidDeaths
--Where location like '%states%'
where continent is not null
--Group By date
order by 1,2
---
Select location, SUM(cast(new_deaths as int)) as TotalDeathCount
From covid..CovidDeaths
--Where location like '%states%'
Where continent is null
and location not in ('World', 'European Union', 'International')
Group by location
order by TotalDeathCount desc
--
Select Location, Population, MAX(total_cases) as HighestInfectionCount, Max((total_cases/population))*100 as PercentPopulationInfected
From covid..CovidDeaths
--Where location like '%states%'
Group by Location, Population
order by PercentPopulationInfected desc
--
Select Location, Population,date, MAX(total_cases) as HighestInfectionCount, Max((total_cases/population))*100 as PercentPopulationInfected
From covid..CovidDeaths
--Where location like '%states%'
Group by Location, Population, date
order by PercentPopulationInfected desc