Knowee
Questions
Features
Study Tools

Raj, a Database Administrator, needs to display the average pay of workersfrom those departments which have more than five employees. He isexperiencing a problem while running the following query:SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5GROUP BY DEPT;Which of the following is a correct query to perform the given task?i. SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT(*) > 5GROUP BY DEPT;ii. SELECT DEPT, AVG(SAL) FROM EMP HAVING COUNT(*) >5 GROUP BY DEPT;iii. SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPTWHERE COUNT(*) > 5;iv. SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPTHAVING COUNT(*) > 5;

Question

Raj, a Database Administrator, needs to display the average pay of workersfrom those departments which have more than five employees. He isexperiencing a problem while running the following query:SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT() > 5GROUP BY DEPT;Which of the following is a correct query to perform the given task?i. SELECT DEPT, AVG(SAL) FROM EMP WHERE COUNT() > 5GROUP BY DEPT;ii. SELECT DEPT, AVG(SAL) FROM EMP HAVING COUNT() >5 GROUP BY DEPT;iii. SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPTWHERE COUNT() > 5;iv. SELECT DEPT, AVG(SAL) FROM EMP GROUP BY DEPTHAVING COUNT(*) > 5;

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

Solution

The correct query to perform the given task is option ii. SELECT DEPT, AVG(SAL) FROM EMP HAVING COUNT(*) > 5 GROUP BY DEPT.

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.Move the function to the SELECT clause and add a GROUP BY clause and a HAVING clause.b.Move the function to the SELECT clause and add a GROUP BY clause.c.Use a subquery in the WHERE clause to compare the average salary value.d.Change the function in the WHERE clause.

Consider the following table Employee.Select the output returned by the following query: SELECT branch AS department, AVG(age) AS average_ageFROM employeeGROUP BY branchHAVING COUNT(*) >= 2ORDER BY average_age DESC;

29. What is the result of the following SQL Query? SELECT COUNT(*), AVG(amount) FROM Orders WHERE amount > 200; Number of orders with amount > 200 and the average amount of these orders.Total number of orders and the average amount of all orders.Number of customers with orders > 200 and the average order amount per customer.Total number of orders > 200 and the average number of orders.

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.

Which SQL statement produces an error? Select one:a.SELECT department_id, job_id, AVG(salary)FROM emp_dept_vuGROUP BY department_id, job_id;b.SELECT job_id, SUM(salary)FROM emp_dept_vuWHERE department_id IN (10,20)GROUP BY job_idHAVING SUM(salary) > 20000;c.None of the statements produce an error; all are valid. d.SELECT department_id, SUM(salary)FROM emp_dept_vuGROUP BY department_id;e.SELECT *FROM emp_dept_vu;

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.