Answer the below with an RA query using the following databases below employee (
ID: 3911740 • Letter: A
Question
Answer the below with an RA query using the following databases below
employee (person_name, street, city)
works (person_name, company_name, salary)
company (company_name, city)
H) Find person names, streets and cities of employees who work for two different companies
I) For each company, find person name, salary, street and city for the highest paid employee of that company
J) For each company, find total number of employees and total number of cities their employees reside
K) Find name and city of the company which has highest-paid employee among employees from all companies, along with the name and salary of this employee
L) Find name and city of any company which has employees living in Lincoln and Omaha. [Meaning of the query: For each of these companies, it has some employees live in Lincoln, and some others live in Omaha. Note no employee can live in to different cities
Explanation / Answer
H)
projection employee.person_name,street,employee.city( count(company_name) = 2 group by employee.person_name (employee join works join company))
I)
projection employee.person_name,salary,street,employee.city( salary =max(salary) group by company.company_name (employee join works join company))
J)
projection count(employee.person_name),count(employee.city) group by company.company_name( (employee join works join company))
K)
projection company.company_name,company_city,employee.person_name,salary ( salary = max(salary) (employee join works join company))
L)
projection company.company_name,company_city( employee.city = 'Lincoln' and employee.city != 'Omaha' or employee.city = 'Omaha' and employee,city != 'Lincoln' (employee join works join company))
DO ask if any doubt. Please upvote.