Knowee
Questions
Features
Study Tools

SELECT c.nameFROM COMPANY cJOIN EMPLOYEE e ON c.company_id= e.company_idJOIN SALARY s ON e.employee_id = s.employee_idGROUP BY c.nameHAVING AVG(s.salary) >=40000

Question

SELECT c.nameFROM COMPANY cJOIN EMPLOYEE e ON c.company_id= e.company_idJOIN SALARY s ON e.employee_id = s.employee_idGROUP BY c.nameHAVING AVG(s.salary) >=40000

🧐 Not the exact question you are looking for?Go ask a question

Solution

This SQL query is designed to select the names of companies where the average salary of their employees is greater than or equal to 40,000.

Here's how it works, step by step:

  1. SELECT c.name: This part of the query is asking to return the names of companies.

  2. FROM COMPANY c: This part of the query is specifying that we're looking at data from the table named 'COMPANY', and we're going to refer to this table as 'c' for the rest of the query.

  3. JOIN EMPLOYEE e ON c.company_id= e.company_id: This part of the query is joining the 'COMPANY' table with the 'EMPLOYEE' table based on matching 'company_id' fields. This means we're combining data from both tables where the 'company_id' in the 'COMPANY' table matches the 'company_id' in the 'EMPLOYEE' table.

  4. JOIN SALARY s ON e.employee_id = s.employee_id: This part of the query is further joining the 'SALARY' table with the already combined 'COMPANY' and 'EMPLOYEE' tables based on matching 'employee_id' fields. This means we're combining data from all three tables where the 'employee_id' in the 'EMPLOYEE' table matches the 'employee_id' in the 'SALARY' table.

  5. GROUP BY c.name: This part of the query is grouping the results by the name of the company. This means that the data will be organized by company name.

  6. HAVING AVG(s.salary) >=40000: This part of the query is filtering the results to only include companies where the average salary (as calculated from the 'SALARY' table) is greater than or equal to 40,000.

This problem has been solved

Similar Questions

To display the names of employees who earns more than the average salary of allemployees.SELECT last_name, first_nameFROMemployeeWHEREsalary > AVG(salary);Which change should you make to achieve the desired results?Select one:a.Change the function in the WHERE clause.b.Move the function to the SELECT clause and add a GROUP BY clause.c.Move the function to the SELECT clause and add a GROUP BY clause and a HAVING clause.d.Use a subquery in the WHERE clause to compare the average salary value

Question 11What does this code do?12345678SELECT e.employee_id, e.first_name, e.last_name, e.salaryFROM employees eWHERE e.salary > (  SELECT AVG(salary)  FROM employees  WHERE department_id = e.department_id); 1 pointIt finds employees who earn more than the average salary in their department.It calculates the average salary for all employees.It groups employees by department.It joins the employees table with itself.

What will the following SQL query return? SELECT AVG(salary) AS average_salary FROM employees WHERE department_id IN (SELECT department_id FROM departments WHERE department_name = 'IT');Select one:a. The number of employees in the IT department.b. The total salary of employees in the IT department.c. The highest salary of employees in the IT department.d. The average salary of employees in the IT department.

Select the correct answerThe Employee table holds all employees including their managers. Every employee has an Id, and there is also a column for the manager Id.IdNameSalaryManagerId1Joe7000032Henry8000043Sam60000NULL4Max90000NULLGiven the Employee table, write a SQL query that finds out employees who earn more than their managers. For the above table, Joe is the only employee who earns more than his manager.EmployeeJoeOptionsselect e.Name as Employee from Employeeas e inner join Employeeselect e.Name as Employee to Employeefrom e inner join Employee has m on e.ManagerId = m.id where e.Salary > m.Salary;select e.Name as Employee from Employeeas e inner join Employee as m on e.ManagerId = m.idwhere e.Salary > m.Salary;select e.Name as Employeefrom Employee on e.ManagerId = m.id where e.Salary > m.Salary;

Find the following table EmployeeDetails, with the attributes EmployeeID, EmpName, Designation, Salary, DeptNo. You are assigned to a task of providing the solution to the operations department by writing the query which displays the employeeID and the Designation of all the employees whose Salaries are more than the Salary of employees designated as ManagerC

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.