Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

MUHAMMAD FAHAD

CMS: 356324
Submitted to: Waqas Ahmed
11-12-2020

DATABASE SYSTEMS

LAB-6
TASKS
Task-1: Select all employees from ‘EE’, ‘IS’ and ‘CSE’ department using
UNION
operator.

STEPS
 First we CREATE the table “EMPLOYEE”
 then select the names of the employees in department CSE, IS and EE using
UNION Command

Task-2: Display all employees name and salary, whose salary is lesser
than
maximum salary of the company and job title starts with ‘S’.

STEPS
 In this task we use the same table EMPLOYEE
 Then we see the details of the employees whose salary is lesser than
maximum salary of the company and job title starts with ‘S’ using
SUBQUERIES

Task-3 Write a query to find all the employees who work in the same
job as ‘ALI’.

STEPS
 First, we take the same table “EMPLOYEE” from the earlier task
 Now we use SELECT and Subquery to display the departments as asked

Task-4: Write a query to display information of employees who earn


more than any employee in dept 10.
STEPS
 First, we take the same table “EMPLOYEE” from the last task
 We use ANY and SUBQUERY to display the required task

Task-5: Display the employees who have the same job as ‘ALI’ and
whose salary <=‘NASIR’.

STEPS
 First, we take the same table “EMPLOYEE” from the last task
 We use AND and SUBQUERY to display the required result

Task-6: Write a query to display the name and job of all


employees in dept 20 whohave a job that someone in the CSE
dept as well.
STEPS
 First, we take the same table “EMPLOYEE” from the task
 Now we use the combination of AND and SUBQUERY to display the output

Task-7: Write a query to list all the employees who salary is <
the average salary of their own dept.

STEPS
 First, we take the same table “EMPLOYEE” from the Task
 We use GROUP BY and SUBQUERY in this task

Task-8 : Write a query to list the employees in dept 10 with the


same job as anyone in the ‘CSE’ department

STEPS
 First, we take the same table “EMPLOYEE” from the last Task
 Now we use the combination of AND and SUBQUERY to display the output
 The results are shown

Task-9 Write a query to create a view, which list the


employees including dept name.
STEPS
 First, we take the same table “EMPLOYEE” from the Task
 Then we create a ViewTable using the CREATE
 Then we display it using the SELECT command.

You might also like