Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GroupConcat: missing "ORDER BY" features #1101

Open
roniemartinez opened this issue Aug 8, 2024 · 0 comments
Open

GroupConcat: missing "ORDER BY" features #1101

roniemartinez opened this issue Aug 8, 2024 · 0 comments

Comments

@roniemartinez
Copy link

Description

Currently, GroupConcat() only accepts "asc", "desc" and None for ordering parameter.

But GROUP_CONCAT supports more complex features in ORDER BY.

As an example, multiple columns and expressions:

GROUP_CONCAT(column1 ORDER BY column2, NATURAL_SORT_KEY(column3) SEPARATOR ', ') AS mycolumn

In the example above, the ordering can be done using "other" columns (column2 and column3) similar to a standard "ORDER BY". (We use the raw SQL above since GroupConcat() don't support this at the moment)

As shown in the MySQL docs:

GROUP_CONCAT([DISTINCT] expr [,expr ...]
             [ORDER BY {unsigned_integer | col_name | expr}
                 [ASC | DESC] [,col_name ...]]
             [SEPARATOR str_val])

and MariaDB docs even added LIMIT support:

GROUP_CONCAT([DISTINCT] expr [,expr ...]
             [ORDER BY {unsigned_integer | col_name | expr}
                 [ASC | DESC] [,col_name ...]]
             [SEPARATOR str_val]
             [LIMIT {[offset,] row_count | row_count OFFSET offset}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant