Oracle Database SQL — Question 41
The SALES table has columns PROD_ID and QUANTITY_SOLD of data type NUMBER.
Which two queries execute successfully? (Choose two.)
Answer options
- A. SELECT prod_id FROM sales WHERE quantity_sold > 55000 AND COUNT(*) > 10 GROUP BY COUNT(*) > 10;
- B. SELECT prod_id FROM sales WHERE quantity_sold > 55000 GROUP BY prod_id HAVING COUNT(*) > 10;
- C. SELECT COUNT(prod_id) FROM sales GROUP BY prod_id WHERE quantity_sold > 55000;
- D. SELECT prod_id FROM sales WHERE quantity_sold > 55000 AND COUNT(*) > 10 GROUP BY prod_id HAVING COUNT(*) > 10;
- E. SELECT COUNT(prod_id) FROM sales WHERE quantity_sold > 55000 GROUP BY prod_id;
Correct answer: B, E
Explanation
Option B is correct because it properly groups the results by prod_id and uses HAVING to filter those groups based on the count of records. Option E is also correct as it counts prod_id while filtering by quantity_sold and groups by prod_id. Options A, C, and D have syntax errors or use COUNT improperly, which will lead to execution failures.