Skip to main content

Example 5. GROUP BY with ORDER BY

Premium
2 min read

Comments & Discussion

AE
Amit Erandole ✓ Link copied!

I think this more accurately shows how to query total products ordered by each user, not as mentioned in the text above, order (these entries) by the total orders count. That's why we count the product_id column in the pivot table and not the id column in the orders table

P
porrapat ✓ Link copied!

In the SQL query, they missed.

order by `total_products` desc

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.