summaryrefslogtreecommitdiff
path: root/labs/2
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-01-01 13:03:14 -0700
committermo khan <mo.khan@gmail.com>2020-01-01 13:03:14 -0700
commit5a18300743c66582485722c7047a323245752d44 (patch)
tree4a212b4878b1a6ce13b116f7e73b1430906eb278 /labs/2
parentbcbbacae9b14c0e233c3c3027ad9943db1fd338d (diff)
Find female employees making more than $27K. I do not understand the "average" part of the task
Diffstat (limited to 'labs/2')
-rw-r--r--labs/2/README.md2
-rw-r--r--labs/2/run.sql7
2 files changed, 8 insertions, 1 deletions
diff --git a/labs/2/README.md b/labs/2/README.md
index ae5e05c..2ef04a2 100644
--- a/labs/2/README.md
+++ b/labs/2/README.md
@@ -70,7 +70,7 @@ Indicates the name (Consumer Products, Industrial Products, and Research) and nu
Your query should make use of your trigger (from c) to ensure database integrity.
* [x] Write an SQL statement to retrieve the number of people working in each of the departments responsible for mobile technology projects.
-* [ ] Retrieve the department name and the number of female employees working for each department whose average salary is more than 27K.
+* [X] Retrieve the department name and the number of female employees working for each department whose average salary is more than 27K.
* [ ] For some strategic decisions, the president of the company needs summary data about the departments.
For each department,
diff --git a/labs/2/run.sql b/labs/2/run.sql
index 0b070e2..ca943bf 100644
--- a/labs/2/run.sql
+++ b/labs/2/run.sql
@@ -104,3 +104,10 @@ INNER JOIN employees on employees.dno = departments.dnumber
INNER JOIN projects on projects.dnum = departments.dnumber
WHERE projects.pname LIKE 'Mobile %'
GROUP BY departments.dnumber;
+
+SELECT d.dname, count(distinct(e.sin))
+FROM departments d
+INNER JOIN employees e on e.dno = d.dnumber
+WHERE e.gender = 'F'
+AND e.salary > 27000
+GROUP BY d.dnumber;