1
23kviews
Consider the following employee database and write SQL queries for the following
1 Answer
written 6.2 years ago by |
Consider the Employee Database
Employee (emp_name, street, city, date_of_joining)
Works(emp_name, company_name, salary)
Company (company_name, city)
Manager (emp_name, manager_name)
i)Modify the database so that “Deepa” lives in “Pune”
UPDATE Employee
SET city=’Pune’
Where emp_name=’Deepa’
ii)Give all employees of “XYZ corporation” a 10% rise in salary
UPDATE Works
SET salary=salary*1.10
WHERE company_name=’XYZ corporation’
iii)List all employee who lives in the same city as their company city
SELECT emp_name
FROM Employee e, Company c, Works w
WHERE e.empname = w.empname
&&w.company_name = c.company_name
&&e.city = c.city
iv)Display all employees who joined in the month of “March”
SELECT emp_nameFROM Employee
WHERE date_of_joining =’MARCH’
v)Find all employees who earn more than average salary of all the employees of their company
SELECT emp_name, salary
FROM Employee.e, Works.w ON e.emp_name=w.emp_name
WHERE w.salary>avg(w.salary)