Write a SELECT statement that returns one row for each category that has products with these columns: The CategoryName column from the Categories table The count of the products in the Products table The list price of the most expensive product in the Products table Sort the result set so the category with the most products appears first.

Respuesta :

Answer:

SELECT C.CategoryName,COUNT(P.CategoryID) AS NumberOfProducts, MAX(P.ListPrice) AS

MostExpensiveProduct

FROM Categories C, Products P

WHERE P.CategoryID=C.CategoryID

GROUP BY C.CategoryName ORDER BY COUNT(*) desc;

Explanation:

This program uses a SELECT statement to arrive at its outout or perform its function.

The SELECT statement helps to return one row for each category that has products.

This is done by Sorting the result set so the category with the most products appears first.