Sección 2. Capítulo 2
single
Challenge: Top-Selling Products
Desliza para mostrar el menú
Tarea
Swipe to start coding
Write a query to list the top 3 products by total sales using a subquery in the FROM section.
- Use the
salestable to calculate the total sales for each product. - In a nested subquery inside the FROM section, group sales by
product_idand sum thetotal_amountfor each product. - Order the results by total sales in descending order and limit the output to the top 3 products.
- In the outer query, join this subquery result with the
productstable to get the product name and the total sales. - The result should display the product name and its total sales.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 2
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla