How to apply limit() and sort() on the entire queryresult

I want to apply limit() and sort() on the entire queryresult and not just on the individual tables.
I store multiple field values per DB-entry and reassemble those rows with pivot(). After that I want to limit the amount of rows returned or sort the pivoted rows.
Unfortunately I didnt find a solution yet, because limit() and sort() apply on the individual tables and not the pivoted result-table, even if I use limit() after pivot().
At the moment I am forced to query all results and apply a limit in java. That is very resource intensitive. Is there a way to do it directly with flux?

Best regards,

Hello @Overflowed,
You can apply a |>group() first which will effectively ungroup your tables. Then yoou can apply a limit or sort across everything.
Try that first and let me know how it goes? Otherwise I might need some more information on your data and the query you’ve tried etc

1 Like

Hello @Anaisdg ,
|>group() is exactly what I was looking for!
Thank you very much!

1 Like

Yay! You’re welcome :slight_smile: