Sample Header Ad - 728x90

How can I paginate when ordering by `date_bin`?

2 votes
1 answer
264 views
I have the following query
SELECT u.update_time, about_me
FROM users u
ORDER BY date_bin('14 days', u.update_time, '2023-04-07 23:11:56.471560Z') DESC, LENGTH(u.about_me) DESC, u.user_id;
I get the following: | update_time | about_me | | -------- | -------------- | | 2023-04-06 19:59:56.771388 +00:00 | Hello! How are you? | | 2023-04-02 03:31:09.833925 +00:00 | Hello!!! | | 2023-04-06 00:36:26.822102 +00:00 | Hello! | | 2023-04-05 19:16:20.968274 +00:00 | Hey! | I now want to only get everything after the 3rd row. So I would do the following:
SELECT u.update_time, about_me
FROM users u
WHERE (date_bin('14 days', u.update_time, '2023-04-07 23:11:56.471560Z'), LENGTH(u.about_me)) <
      ('2023-04-07 03:05:24.990233 +00:00', 6)
ORDER BY date_bin('14 days', u.update_time, '2023-04-07 23:11:56.471560Z') DESC, LENGTH(u.about_me) DESC, u.user_id;
But the issue is that I'm still getting the exact same results, it's as if the WHERE isn't working. How can I paginate the query?
Asked by DanMossa (145 rep)
Apr 7, 2023, 06:31 AM
Last activity: Apr 11, 2023, 12:26 AM