Skip to content

Document parenthesized branches of unions in OQL - #11812

Open
passalaqua wants to merge 4 commits into
mendix:developmentfrom
passalaqua:dat/docs/lparen-union-rparen
Open

Document parenthesized branches of unions in OQL#11812
passalaqua wants to merge 4 commits into
mendix:developmentfrom
passalaqua:dat/docs/lparen-union-rparen

Conversation

@passalaqua

Copy link
Copy Markdown
Contributor

Available starting with 11.15.0

@passalaqua
passalaqua marked this pull request as draft August 25, 2026 12:28
@passalaqua
passalaqua force-pushed the dat/docs/lparen-union-rparen branch from a33f1e6 to 4ee8c0c Compare August 25, 2026 12:41
@passalaqua
passalaqua marked this pull request as ready for review August 25, 2026 12:42
@MarkvanMents
MarkvanMents self-requested a review August 25, 2026 12:45
@MarkvanMents MarkvanMents self-assigned this Aug 25, 2026
@basdebakker

Copy link
Copy Markdown
Member

Approved by datastorage team.


You can wrap an individual subquery in parentheses to sort and limit only the results from that subquery rather than the sorting and limiting applying to the result of the `UNION`. This is done by giving each subquery its own `ORDER BY`, `LIMIT` and `OFFSET` clauses.

For example, the following query uses `UNION` to return the brand and location with the highest and lowest stock levels, sorted in ascending order of the amount of stock.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second select in the example contains an offset, so it's the highest and second lowest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants