C is correct, and by the way is also the only valid query on the question.
A) ORA-00937: not a single-group group function
B)ORA-00979: not a GROUP BY expression
D)ORA-00937: not a single-group group function
A - false; returns error ORA-00937: not a single-group group function; first occurence of dept_id is marked as the cause of the error
B - false; returns error ORA-00979: not a GROUP BY expression; join_date is marked as the cause of the error
C - true; columns mentioned between SELECT and FROM keywords are also mentioned after GROUP BY clause
D - false; same as answer A
A (FALSE). SELECT dept_id, AVG(MAX(salary)) FROM employees GROUP BY dept_id;
select DEPARTMENT_ID, AVG(MAX(SALARY)) from EMPLOYEES group by DEPARTMENT_ID;
ERROR at line 1:
ORA-00937: not a single-group group function
B (FALSE). SELECT dept_id, join_date, SUM(salary) FROM employees GROUP BY dept_id;
select DEPARTMENT_ID, HIRE_DATE,sum(salary) from EMPLOYEES group by DEPARTMENT_ID
*
ERROR at line 1:
ORA-00979: not a GROUP BY expression
C (TRUE). SELECT dept_id, join_date, SUM(salary) FROM employees GROUP BY dept_id, join_date;
SQL> select DEPARTMENT_ID, HIRE_DATE,SUM(SALARY) from EMPLOYEES group by DEPARTMENT_ID , HIRE_DATE;
DEPARTMENT_ID HIRE_DATE SUM(SALARY)
------------- --------- -----------
60 25-JUN-05 4800
D (FALSE). SELECT dept_id, MAX(AVG(salary)) FROM employees GROUP BY dept_id;
SELECT DEPARTMENT_ID , MAX(AVG(salary)) FROM employees GROUP BY DEPARTMENT_ID
*
ERROR at line 1:
ORA-00937: not a single-group group function
A and D are wrong simply because we cannot use nested group functions while grouping by any specific column, we should use the whole table as one group (by not using a group by clause) otherwise the query would not make sense.
A is wrong. When using nested aggregate functions you are not allowed to display any additional column(s) other than the nested aggregate function.
B is wrong. Missing the join_date column in the GROUP BY clause. The rule states: "Any column in the select list that's not part of an aggregate function MUST BE in the group by clause".
C is correct.
D is wrong. Same issue as with option A.
C is the correct answer:
SELECT dept_id, join_date, SUM(salary) FROM employees GROUP BY dept_id, join_date;
All options with non-groupable functions need to be added in GROUP BY.
upvoted 1 times
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
you1234
Highly Voted 4 years agodanito
Highly Voted 4 years, 1 month agoEkos
3 years, 7 months ago8hyehye8
Most Recent 3 months, 2 weeks agoguimaleo
4 months, 3 weeks agonautil2
8 months, 2 weeks agoauwia
1 year agofthusa
1 year, 1 month agoFelipeC
1 year, 4 months agoOCP19c
1 year, 10 months agomamadu
1 year agoalgerianphoenix
2 years, 2 months agoFranky_T
2 years, 2 months agoSankar1406
2 years, 3 months agosagartake
2 years, 3 months agoalgerianphoenix
2 years, 2 months agoryuah
2 years, 6 months agoTaush
2 years, 10 months agoGuhborges
2 years, 10 months ago