SALES テーブルには、データ型 NUMBER の列 PROD_ID および QUANTITY_SOLD があります。正常に実行される 2 つのクエリはどれですか?
正解:A,B
When crafting SQL queries, especially those involving aggregate functions and GROUP BY clauses, correct syntax and logical order of SQL clauses are crucial. Here's why A and B are the correct answers: A: Correct. This query uses COUNT() as an aggregate function correctly with a GROUP BY clause. It counts the number of prod_id entries for each product where quantity_sold exceeds 55000, grouped by prod_id. B: Correct. This query selects prod_id for groups having more than 10 rows where quantity_sold exceeds 55000. The GROUP BY and HAVING clauses are used correctly. C: Incorrect. The WHERE clause should be placed before the GROUP BY clause. The correct order of clauses is essential for query execution. D: Incorrect. This query attempts to use an aggregate function (COUNT(*)) in the WHERE clause and improperly in the GROUP BY clause, which is not allowed. E: Incorrect. Similar to D, it incorrectly attempts to use COUNT(*) in the WHERE clause, which is syntactically incorrect.