In PostgreSQL können wir die folgenden Queries wie folgt lösen:
Anzahl Projekte pro Department:
SELECT Department.id, Department.name, COUNT(Project.id) as count_projectFROM DepartmentINNER JOIN Project on Department.id = Project.department_idGROUP BY Department.id;
Durchschnittliche Dauer aller Projekte:
SELECT AVG(end_date - start_date) as avg_project_duration_daysFROM Project;
Durchschnittliche Projektdauer pro Department:
SELECT Department.id, Department.name, AVG(Project.end_date - Project.start_date) as avg_proj_duration_daysFROM DepartmentINNER JOIN Project on Department.id = Project.department_idGROUP BY Department.id;
Durchschnittliche Satisfaction pro Department:
SELECT Department.id, Department.name, AVG(CAST(Employee.satisfied AS INTEGER)) as avg_satisfiedFROM DepartmentINNER JOIN Employee on Department.id = Employee.department_idGROUP BY Department.id;
Durchschnittliche Projektdauer des “Technology” Departments:
SELECT Department.id, Department.name, AVG(Project.end_date - Project.start_date) as avg_proj_duration_daysFROM DepartmentINNER JOIN Project on Department.id = Project.department_idWHERE Department.name = 'Technology'GROUP BY Department.id;
Satisfaction des “Technology” Departments:
SELECT Department.id, Department.name, AVG(CAST(Employee.satisfied AS INTEGER)) as avg_satisfiedFROM DepartmentINNER JOIN Employee on Department.id = Employee.department_idWHERE Department.name = 'Technology'GROUP BY Department.id;