Skip to main content
3 of 5
tag, add info from comment
Erwin Brandstetter
  • 182.1k
  • 28
  • 457
  • 620

Possible to order column in range of another column?

I have a table with the following two columns: about and create_time.

I want to receive a list of rows that are ordered length(about) DESC but only per chunk of time. For example:

If I have the following rows:

about create_time
Hello 1/1/2023
Hey 1/5/2023
My name is Daniel 2/1/2023
Hi 2/8/2023
Hello 3/4/2023
What's up 3/2/2023
I like to eat 11/5/2022

And I want to order them per length of about but only in chunks of 30 days, I'd expect to get the following:

about create_time
Hello 3/4/2023
What's up 3/2/2023
My name is Daniel 2/1/2023
Hi 2/8/2023
Hey 1/5/2023
Hello 1/1/2023
I like to eat 11/5/2022

So they're ordered by length of about me but per chunk of 30 days, starting from now().