-
Notifications
You must be signed in to change notification settings - Fork 0
/
Health data analysis.sql
62 lines (43 loc) · 1.38 KB
/
Health data analysis.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
-- 1. Count & percentage of F vs M that have ocd & -- average obsession score by gender
SELECT
Gender,
count(`Patient ID`) as patient_count,
round(avg(`Y-BOCS Score (Obsessions)`),2) as abg_obs_score
FROM health_data.ocd_patient_dataset
GROUP BY 1
ORDER BY 2;
-- 2. Count of patients by ethnicities & their respective average obsession score
select
Ethnicity,
count(`Patient ID`) as patient_count,
avg(`Y-BOCS Score (Obsessions)`) as obs_score
FROM health_data.ocd_patient_dataset
Group by 1
Order by 2;
-- 3.number of people diagnosed with ocd MoM
-- alter Table health_data.ocd_patient_dataset
-- modify `OCD Diagnosis Date` date; change this column to date format
select
date_format(`OCD Diagnosis Date`, '%Y-%m-01 00:00:00') as month,
count(`Patient ID`) patient_count
FROM health_data.ocd_patient_dataset
group by 1
Order by 1;
-- 4. What is the most common Obsession Type (Count) & it's respective Average Obsession Score
Select
`Obsession Type`,
count(`Patient ID`) as patient_count,
round(avg(`Y-BOCS Score (Obsessions)`),2) as obs_score
from health_data.ocd_patient_dataset
group by 1
Order by 2
;
-- 5. What is the most common Compulsion type (Count) & it's respective Average Obsession Score
Select
`Compulsion Type`,
count(`Patient ID`) as patient_count,
round(avg(`Y-BOCS Score (Obsessions)`),2) as obs_score
from health_data.ocd_patient_dataset
group by 1
Order by 2
;