Assignment # 5
Assignment # 5
AND TECHNOLOGY
(Mardan)
IDS Assignment # 5
Submittet to Sir Zafar Ali
Name Obaid Ullah
Subject ; IDS (Theory)
Semester ; 4th
Section ; “B”
Roll No ; 35
DEPARMENT OF COMPUTER SOFTWARE ENGINEERING
UNIVERSITY OF ENGINNERING AND TECHNOLOGY
(MARDAN)
For the given Relational Schema, Write SQL queries for the following
EMPLOYEE (Fname, Lname, ECNIC, BirthDate, Address, Sex, Salary, Super_cnic, Dno)
DEPARTMENT (Dname, Dnumber, Mgr_cnic, Mgr_start_date)
DEPT_LOCATIONS (Dnumber, Dlocation)
PROJECT (Pname, Pnumber, Plocation, Dnum)
WORKS_ON (ECNIC, Pno, Hours)
DEPENDENT (ECNIC, Dependent_name, Sex, date_of_birth, Relationship)
1)
FROM DEPARTMENT AS D
GROUP BY D.Dnumber
2) For each project on which more than two employees work, select the project
number, the project name and the number of employees who work on that
project.
4) For each department that has more than five employees, select the department
number and the number of its employees who are making more than
60,000(Threshold changed from 20000 to 60000).
SELECT D.Dnumber AS dept_number, COUNT(e.ECNIC) AS E.Salary
FROM employee AS E
JOIN department AS D ON E.Dno = D.Dnumber AND E.Salary > 60000
AND D.Dnumber IN (SELECT D.Dnumber
FROM employee AS E
JOIN department AS D ON E.Dno = D.Dnumber
GROUP BY D.Dnumber
HAVING COUNT(E.ECNIC) > 5)