2
Which SQL statement produces an error?
Select one:
O SELECT *
FROM emp_dept_vu;
1
O SELECT department_id, SUM(salary)
FROM emp_dept_vu
GROUP BY department_id;
O SELECT department_id, job_id, AVG(salary)
FROM emp_dept_vu
GROUP BY department_id, job_id;
O SELECT job_id, SUM(salary)
FROM emp_dept_vu
WHERE department_id IN (10,20)
GROUP BY job_id
HAVING SUM(salary) > 20000;
O None of the statements produce an error; all are valid.
Answers
Answer:
None of the statements produce an error; all are valid.
Explanation:
Answer:
None of the statements will produce an error. All are valid queries.
Explanation:
Let's see each query one by one:
SELECT * FROM emp_dept_vu;
This query will select all the data from the emp_dept_vu table. There is no error in this query.
SELECT department_id, SUM(salary)
FROM emp_dept_vu
GROUP BY department_id;
This query will select the department id, the sum of the salary from the emp_dept_vu table, and group all the data by the department id. It is also valid.
SELECT department_id, job_id, AVG(salary)
FROM emp_dept_vu
GROUP BY department_id, job_id;
It will select the department id, job id, and average salary from the emp_dept_vu table and group the data by department id and job id. This is also a valid query.
SELECT job_id, SUM(salary)
FROM emp_dept_vu
WHERE department_id IN (10,20)
GROUP BY job_id
HAVING SUM(salary) > 20000;
This query will select the job id, and the sum of the salary from the emp_dept_vu table with the condition where the department id is in the range of 10 to 20 and the sum of the salary is greater than 20,000.
This is also valid.
So there is no invalid statement. Hence no error will be produced.
#SPJ3