Write SQL queries

Consider the following 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)

Mumbai University > Information Technology > Sem 3 > Database Management System

Marks: 10M

Year: May 2016

1 Answer
  • Modify the database so that “Deepa” lives in “Pune”

    UPDATE Employee

    SET city=’Pune’

    Where emp_name=’Deepa’

  • Give all employees of “XYZ corporation” a 10% rise in salary

    UPDATE Works

    SET salary=salary*1.10

    WHERE company_name=’XYZ corporation’

  • List all employee who lives in the same city as their company city

    SELECT emp_nameFROM Employee e, Company c, Works w

    WHERE e.empname = w.empname

    &&w.company_name = c.company_name

    &&e.city = c.city

  • Display all employees who joined in the month of “March”

    SELECT emp_nameFROM Employee

    WHERE date_of_joining =’MARCH’

  • Find all employees who earn more than average salary of all the employees of their company

    SELECT emp_name, salaryFROM Employee.e, Works.wONe.emp_name=w.emp_name

    WHERE w.salary>avg(w.salary)

Please log in to add an answer.