0% found this document useful (0 votes)
12 views7 pages

705 Assignment 1

Uploaded by

khroudishnoor34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

705 Assignment 1

Uploaded by

khroudishnoor34
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Table 1: Department

Table 2: Dependent
Table 3: Employee

Table 4: Projects
Table 5: Works_On:

Table 6: Dept_location:
Q1) Display all employees (Fname, Lname) whose salary is in between 20K and 30K.

Sql Query: SELECT FNAME, LNAME FROM EMPLOYEE WHERE Salary BETWEEN 20000
AND 30000

Output:

Q2) Display all employees (Fname, Lname) whose salary is in between 20K and 30K and
works in the department “Research”.

Sql Query:SELECT FNAME, LNAME FROM EMPLOYEE, DEPARTMENT WHERE (DNAME =


"Research") AND (DNUMBER = DNO) AND (Salary BETWEEN 20000 AND 30000);

Output:

Q2) Display all employee names who are from DELHI and their department locaƟon is
KOLKATA

Sql Query: SELECT FNAME, LNAME FROM EMPLOYEE, DEPT_LOCATIONS WHERE


(DLOCATION = "Kolkata") AND (DNUMBER = DNO) AND (ADDRESS LIKE "%Delhi%");

Output:
Q4) Which employees are working in department “Research” and project number “P-01”.

SQL QUERY: SELECT FNAME, LNAME FROM EMPLOYEE, DEPARTMENT, PROJECT


WHERE (DNAME = "Research") AND (DNUMBER = DNO) AND (PNUMBER = "P-01") AND
(DNUM = DNUMBER);

Output:

Q5) Display list of employees who are either from DELHI or working in a department
located at DELHI.

SQL QUERY: SELECT FNAME, LNAME FROM EMPLOYEE, DEPT_LOCATIONS WHERE


(DNUMBER = DNO) AND ((DLOCATION = "Delhi") OR (ADDRESS LIKE "%Delhi%"));

Output:

Q6) Count number of employees working in department “Research”.

SQL QUERY: SELECT COUNT(*) AS "Employess in Research Dept" FROM EMPLOYEE,


DEPARTMENT WHERE (DNUMBER = DNO) AND (DNAME = "Research");
Output:

Q7) Display all employee names who have no dependent.

SQL QUERY: SELECT FNAME, LNAME FROM EMPLOYEE WHERE NOT EXISTS (SELECT *
FROM DEPENDENT WHERE SSN = ESSN)

Output:

Q8) Display all employee names from department “Research” who have no dependent or
have all dependents born after 01/01/2010

SQL QUERY: SELECT FNAME, LNAME FROM EMPLOYEE, DEPARTMENT WHERE


(DNAME = "Research") AND (DNUMBER = DNO) AND ((SSN NOT IN (SELECT SSN FROM
EMPLOYEE, DEPENDENT WHERE (SSN = ESSN))) OR (SSN IN (SELECT SSN FROM
EMPLOYEE, DEPENDENT WHERE (SSN = ESSN) AND DEPENDENT.BDATE >
"2010-01-01")));

Output:
Q9) What is the average salary of employees in “Research” department

SQL QUERY: SELECT ROUND(AVG(SALARY), 2) AS "Average Salary of Emp in Research"


FROM EMPLOYEE, DEPARTMENT WHERE (DNAME = "Research") AND (DNUMBER = DNO)

Output:

Q10) How many employees are there in the organizaƟon who are working as managers
and have started the managerial job after 01/01/2016.

SQL QUERY: : SELECT COUNT(*) AS "No. of Emp in Managerial Role" FROM EMPLOYEE,
DEPARTMENT WHERE (DNUMBER = DNO) AND (SUPER_SSN = MGR_SSN) AND
(MGR_START_DATE > "2016-01-01");

Output:

You might also like