Imaging a query that delivers "posts" in a specific time period between "from" and "to". A simple query.
Additionally, I need to get ONE record BEFORE and ONE record AFTER what the original query specified.
For example, a table holds these posts:
1 hello 20.08.2023
2 hi 21.08.2023
3 please 22.08.2023
4 bye 23.08.2023
For get_posts("from" => '21.08.2023', to => '22.08.2023')
the origin query delivers:
2 hi
3 please
Now I need to add one row before (1 hello
) and one row after (4 bye
). Possibly as subquery inside the original query?
I read about window functions or subqueries, but I do not know how to start.