Martin works as a Database Administrator for MTech Inc. He designs a database that has a table named Products. He wants to create a report listing different product categories. He does not want to display any duplicate row in the report. Which of the following SELECT statements will Martin use to create the report?
SELECT DISTINCT Product_No, Prod_Category FROM Products;
Correct:
SELECT DISTINCT Product_No, Prod_Category FROM Products;
Explanation:
Answer option D is correct.
The SELECT statement in answer option D will display different product categories in the Products table. It will not display any duplicate values for Product_No and Prod_Category columns because the DISTINCT clause is used. The DISTINCT clause ensures that the resulting rows are unique.
Answer option A is incorrect. It will display the values of Product_No and Prod_Category columns even if they are repeated, as the DISTINCT clause is not used.
Answer options B and C are incorrect because the Prod_Category column is not specified with the GROUP BY clause. If a GROUP BY clause is used with the SELECT statement, all columns in the SELECT statement should either be included in the GROUP BY clause or aggregated using the aggregated function.