Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Top-Selling Products | Nested Subqueries in the FROM section
Practice
Projects
Quizzes & Challenges
Quiz
Challenges
/
Generate Nested Subqueries in SQL
Section 2. Chapitre 2
single

single

bookChallenge: Top-Selling Products

Glissez pour afficher le menu

Tâche

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.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 2
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt