Sectie 2. Hoofdstuk 2
single
Challenge: Top-Selling Products
Veeg om het menu te tonen
Taak
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.
Oplossing
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 2. Hoofdstuk 2
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.