Answer the question
In order to leave comments, you need to log in
How to organize sorting?
There are two types of articles: video and text. Question: is it possible to sort by date of addition and type of article
article with video, after it 2 articles with text, and so on in a cycle, if there are no more articles with video, then simply display text articles.
Answer the question
In order to leave comments, you need to log in
SELECT * FROM (
SELECT
table.*,
CASE
WHEN type='video' THEN row_number() OVER (PARTITION BY type ORDER BY create_date) *2
ELSE row_number() OVER (PARTITION BY type ORDER BY create_date) +1
END ord
FROM table
) result ORDER BY ord, type DESC
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question