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

adding a solution of a challange (Ordering When Concatenating) #274

Open
wants to merge 1 commit into
base: gh-pages
from

Conversation

@SedaArat
Copy link
Contributor

@SedaArat SedaArat commented Dec 12, 2018

No description provided.

@remram44
Copy link
Contributor

@remram44 remram44 commented Dec 12, 2018

Hi @SedaArat, thank you for your contribution! Unfortunately that doesn't work:

sqlite> SELECT group_concat(personal || ' ' || family, ", ") FROM Person ORDER BY family;
William Dyer, Frank Pabodie, Anderson Lake, Valentina Roerich, Frank Danforth

As you can see, Frank Danforth comes last.

@SedaArat
Copy link
Contributor Author

@SedaArat SedaArat commented Dec 13, 2018

Hi @remram44, the list is the same as the list provided as an output. To order the list by surname, it could be: SELECT group_concat(personal || ' ' || family, ", ") FROM person GROUP BY family;

The output is:
Frank Danforth
William Dyer
Anderson Lake
Frank Pabodie
Valentina Roerich

@remram44
Copy link
Contributor

@remram44 remram44 commented Dec 13, 2018

Relying on GROUP BY to sort outputs is not a good idea. SQLite might do it, but other SQL systems might not give out the groups in sorted order.

This new query also introduces an additional bug: if two people have the same family name, only one of them would be printed 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants