-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tableau Portfolio Project SQL Queries.sql
92 lines (75 loc) · 1.63 KB
/
Tableau Portfolio Project SQL Queries.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
-- New script in master.
-- Date: Dec 20, 2022
-- Time: 1:09:27 PM
/*
Queries used for Tableau Project
*/
-- 1.
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
--Where location like '%states%'
where
continent is not null
--Group By date
order by
1,
2
-- 2.
-- We take these out as they are not inluded in the above queries and want to stay consistent
-- European Union is part of Europe
Select
location,
SUM(cast(new_deaths as int)) as TotalDeathCount
From
PortfolioProject..CovidDeaths
--Where location like '%states%'
Where
location not in (
'World', 'European Union', 'International'
)
Group by
location
order by
TotalDeathCount desc
-- 3.
Select
Location,
Population,
MAX(total_cases) as HighestInfectionCount,
MAX((
CAST (
total_cases AS DECIMAL
) / population
)* 100 )as PercentPopulationInfected
From
PortfolioProject..CovidDeaths
--Where location like '%states%'
Group by
Location,
Population
order by
PercentPopulationInfected desc
-- 4.
Select
Location,
Population,
date,
MAX(total_cases) as HighestInfectionCount,
MAX((
CAST (
total_cases AS DECIMAL
) / population
)* 100 )as PercentPopulationInfected
From
PortfolioProject..CovidDeaths
--Where location like '%states%'
Group by
Location,
Population,
date
order by
PercentPopulationInfected desc