Answer the question
In order to leave comments, you need to log in
How to implement sorting?
Hello, the question will seem a little silly to you, but as a beginner you will help me a lot.
And so here's the problem.
There is a table of categories, with a large number of subcategories.
I need to display those with the most subcategories first.
Ie output in descending order.
using ORDER BY how to implement?
Answer the question
In order to leave comments, you need to log in
All categories with subcategories sort by the number of subcategories in the category in descending order
SELECT ALL COUNT(parent_id) OVER(PARTITION BY id) AS idc
, title , key ,desc , parent_id,id
FROM test order by idc desc
SELECT DISTINCT COUNT(parent_id) OVER(PARTITION BY id) idc
, id
FROM test order by idc desc
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question