On trying to have a single query for fetch, with pagination, the following questions arose:
- Is it possible to have subquery with tuple?
where (id, join_date) in (
select distinct id, join_date from ...)
- Is it possible select
distinctof a part of the attributes, notdistinctfor the whole query. - Is it possible to have “order by 1“
The full query is something like:
select *
from users u1
join files f1 on u1.id = f1.user_id
where (u1.id, u1.join_date) in (
select distinct u2.id, u2.join_date
from users u2
join files f2 on u2.id = f2.user_id
where f2.mime_type = 'pdf'
order by u2.join_date, 1 offset 0 limit 5
)
order by u1.join_date, u1.id;
If this makes sense, feature requests could be created.
Thanks.