The first query is syntactically incorrect. You cannot use the COUNT function in the WHERE clause.
The second query is also incorrect. The HAVING clause is used to filter the results of an aggregation, and it should be used after the GROUP BY clause, not after the WHERE clause.
The third query is also incorrect for the same reason as the second one. The HAVING clause should come after the GROUP BY clause.
The fourth query is correct and will work as expected. It filters rows where the department_id is not equal to 90 using the WHERE clause, groups the remaining rows by department_id, and then applies the HAVING clause to count the rows within each group and filter out groups where the count is greater than or equal to 3.
D is the answer. This query is correct. The WHERE clause correctly filters rows before aggregation (i.e., excludes rows where department_id = 90), and the HAVING clause correctly filters the grouped results (i.e., only returns groups where the count of rows is greater than or equal to 3).
Conclusion: This query will not fail.
I tried it out in Oracle's Apex (Db v19C), using a data set from the internet.
SELECT id
FROM TITANIC
HAVING ID = 1
GROUP BY ID;
It does not affect the result if you use HAVING and GROUP BY in a different position from one to another.
It's a mess! the first three are incorrect for the semicolon
upvoted 3 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.
darkma
Highly Voted 9 months, 3 weeks agoJayaprasanthGurunathan
3 weeks, 2 days agoNSilva
2 months, 2 weeks agoalelejaja
Most Recent 1 month, 2 weeks agom_darwish
1 month, 3 weeks agoMIGHTYSTUNNERS
2 months, 2 weeks agozouve
1 year agofgramos
1 year, 1 month agoyanoolthecool
11 months, 3 weeks agokarols32
1 year, 2 months agoOrxan_H
1 year, 2 months agoRonit_8055
1 year, 5 months agoTheOracleWasTaken
11 months, 2 weeks agoJCKOMI
1 year, 6 months agoMZEnuovazelanda
1 year, 10 months ago