Answer the question
In order to leave comments, you need to log in
How to display the most popular product category?
I practice here: www.w3schools.com/sql/trysql.asp?filename=trysql_s...
How to display the most popular category?
Which has the largest number of products.
Stopped here:
SELECT c.CategoryName,c.CategoryID
FROM [Categories] c
INNER JOIN Products p ON c.CategoryID = p.CategoryID
Answer the question
In order to leave comments, you need to log in
SELECT c.*, COUNT(1) as cnt FROM Categories as c
LEFT JOIN products as p ON c.CategoryID = p.CategoryID
GROUP by p.CategoryID
ORDER BY cnt DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question