Osio 2. Luku 2
single
Challenge: Top-Selling Products
Pyyhkäise näyttääksesi valikon
Tehtävä
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.
Ratkaisu
Oliko kaikki selvää?
Kiitos palautteestasi!
Osio 2. Luku 2
single
Kysy tekoälyä
Kysy tekoälyä
Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme