Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Top-Selling Products | Nested Subqueries in the FROM section
/
Generate Nested Subqueries in SQL
Seção 2. Capítulo 2
single

single

bookChallenge: Top-Selling Products

Deslize para mostrar o menu

Tarefa

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 sales table to calculate the total sales for each product.
  • In a nested subquery inside the FROM section, group sales by product_id and sum the total_amount for 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 products table to get the product name and the total sales.
  • The result should display the product name and its total sales.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 2. Capítulo 2
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

some-alt