Professional Documents
Culture Documents
Lectuer-6 Database Design and Applications: BITS Pilani
Lectuer-6 Database Design and Applications: BITS Pilani
First Semester
2020-21
Contents
• Left join returns all the rows from left table combine with the
matching rows of the right table. If you get no matching tuples
in the right table it returns NULL values.
• Right join returns all the rows from right table combine with
the matching rows of the left table. If you get no matching in
the left table it returns NULL values.
on e.dno=d.dno;
Query: Find the sum of the salaries of all employees, the maximum
salary, the minimum salary, and the average salary.
SELECT SUM (Salary), MAX (Salary), MIN (Salary), AVG (Salary)
FROM EMPLOYEE;
Query: Find the sum of the salaries of all employees of the ‘Research’
department, as well as the maximum salary, the minimum salary,
and the average salary in this department.
SELECT SUM (Salary), MAX (Salary), MIN (Salary), AVG (Salary)
FROM (EMPLOYEE JOIN DEPARTMENT ON Dno=Dnumber)
WHERE Dname=‘Research’;
Example 1:
CREATE VIEW EMP_DETAILS
AS SELECT FNAME,LNAME FROM EMLOYEE
Example 2:
CREATE VIEW WORKS_ON1
AS SELECT Fname, Lname, Pname, working_hours
FROM EMPLOYEE, PROJECT, WORKS_ON
WHERE Ssn=Essn AND Pnum=Pnumber;