-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQL_TASK_PROJECT (solution).sql
235 lines (151 loc) · 4.92 KB
/
SQL_TASK_PROJECT (solution).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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
create database sql_task;
use sql_task;
show tables;
-- 1. What is the gender distribution of respondents from India?
SELECT * FROM dataset;
SELECT Gender, COUNT(*) AS COUNT
FROM dataset
WHERE Country="INDIA"
GROUP BY Gender;
-- 2. What percentage of respondents from India are interested in education abroad and sponsorship?
SELECT
(COUNT(*) * 100.0 /
(SELECT COUNT(*)
FROM dataset
WHERE country = 'India')
) AS percentage
FROM dataset
WHERE country = 'India'
AND Higher_Education_Aspiration IN ('Yes', 'Needs a sponsor');
-- 3. What are the 6 top influences on career aspirations for respondents in India?
SELECT
Influencing_Factors,
COUNT(*) AS influence_count
FROM dataset
WHERE country = 'India'
GROUP BY Influencing_Factors
ORDER BY influence_count DESC
LIMIT 6;
-- 4. How do career aspiration influences vary by gender in India?
SELECT
Gender,
Higher_Education_Aspiration,
COUNT(*) AS influence_count
FROM dataset
WHERE country = 'India'
GROUP BY Gender,Higher_Education_Aspiration
ORDER BY Gender, Higher_Education_Aspiration ;
-- 5. What percentage of respondents are willing to work for a company for at least 3 years?
SELECT
(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM dataset)) AS percentage
FROM dataset
WHERE 3_year_tenurity = 'yes';
-- 6. How many respondents prefer to work for socially impactful companies?
SELECT
COUNT(*) AS respondent_count
FROM dataset
WHERE Likley_Rate_For_Unethical_Company >= 5;
-- 7. How does the preference for socially impactful companies vary by gender?
SELECT
gender,
COUNT(*) AS respondent_count
FROM dataset
WHERE Likley_Rate_For_Unethical_Company >= 5
GROUP BY gender
ORDER BY respondent_count DESC;
-- 8. What is the distribution of minimum expected salary in the first three years among respondents?
SELECT
Minimum_expected_in_hand_monthly_salary_after_3_years,
COUNT(*) AS respondent_count
FROM dataset
GROUP BY Minimum_expected_in_hand_monthly_salary_after_3_years
ORDER BY Minimum_expected_in_hand_monthly_salary_after_3_years
DESC;
-- 9. What is the expected minimum monthly salary in hand?
SELECT
Minimum_expected_in_hand_monthly_salary_after_3_years
FROM dataset
GROUP BY Minimum_expected_in_hand_monthly_salary_after_3_years
ORDER BY Minimum_expected_in_hand_monthly_salary_after_3_years
DESC;
-- 10. What percentage of respondents prefer remote working?
SELECT
(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM dataset)) AS percentage
FROM dataset
WHERE work_in_environment = 'Remote_work';
-- 11. What is the preferred number of daily work hours?
SELECT
work_in_environment,
COUNT(*) AS respondent_count
FROM dataset where work_in_environment = 'Every_Day_Office_work'
GROUP BY work_in_environment
ORDER BY work_in_environment ASC;
-- 12. What are the common work frustrations among respondents?
SELECT
frustration,
COUNT(*) AS respondent_count
FROM dataset
GROUP BY frustration
ORDER BY respondent_count DESC;
-- 13. How does the need for work-life balance interventions vary by gender?
SELECT
gender,
COUNT(*) AS respondent_count
FROM dataset
WHERE need_work_life_balance = 'Yes'
GROUP BY gender
ORDER BY respondent_count DESC;
-- 14. How many respondents are willing to work under an abusive manager?
SELECT
COUNT(*) AS respondent_count
FROM dataset
WHERE Manager_would_you_work_for_without_looking_into_your_watch = 'Yes';
-- 15. What is the distribution of minimum expected salary after five years?
SELECT
Minimum_expected_in_hand_monthly_salary_after_5_years,
COUNT(*) AS respondent_count
FROM dataset
GROUP BY Minimum_expected_in_hand_monthly_salary_after_5_years
ORDER BY Minimum_expected_in_hand_monthly_salary_after_5_years ASC;
-- 16. What are the remote working preferences by gender?
SELECT
gender,
COUNT(*) AS respondent_count
FROM dataset where work_in_environment = 'remote_work'
GROUP BY gender
ORDER BY gender, respondent_count ;
-- 17. What are the top work frustrations for each gender?
WITH GenderFrustrations AS (
SELECT
gender,
frustration,
COUNT(*) AS frustration_count
FROM respondents
GROUP BY gender, frustration
),
RankedFrustrations AS (
SELECT
gender,
frustration,
frustration_count,
RANK() OVER (PARTITION BY gender ORDER BY frustration_count DESC) AS ranked
FROM GenderFrustrations
)
SELECT
gender,
frustration,
frustration_count
FROM RankedFrustrations
WHERE ranked = 1;
-- 18. What factors boost work happiness and productivity for respondents?
SELECT
happiness_factors,
COUNT(*) AS respondent_count
FROM respondents
GROUP BY happiness_factors
ORDER BY respondent_count DESC;
-- 19. What percentage of respondents need sponsorship for education abroad?
SELECT
(COUNT(*) * 100.0 / (SELECT COUNT(*) FROM dataset)) AS sponsorship_percentage
FROM dataset
WHERE Higher_Education_Aspiration = 'Needs a sponsor';