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

Ordering When Concatenating exercise in aggregation section has no solution #288

Open
colinsauze opened this issue Jul 23, 2019 · 5 comments
Open

Comments

@colinsauze
Copy link

@colinsauze colinsauze commented Jul 23, 2019

There's no solution for the "Ordering When Concatenating" exercise in the aggregation section (section 6). I can't quite work out a complete solution which reports the answer on one line.
The nearest I can get is:

SELECT group_concat(personal || ' ' || family, ' ') FROM Person order by family;

which produces the wrong order:

William Dyer Frank Pabodie Anderson Lake Valentina Roerich Frank Danforth

or

SELECT personal || ' ' || family FROM Person order by family;
Frank Danforth
William Dyer
Anderson Lake
Frank Pabodie
Valentina Roerich

produces the right order but uses multiple lines.

Does anyone have the correct solution to this?

@remram44
Copy link
Contributor

@remram44 remram44 commented Jul 23, 2019

(see also #158 (comment), PR #274)

@remram44
Copy link
Contributor

@remram44 remram44 commented Jul 23, 2019

Honestly my suggestion is just removing this exercise.

@colinsauze
Copy link
Author

@colinsauze colinsauze commented Jul 24, 2019

Reading it did leave me wondering what the question is trying to teach. It feels like this isn't the most useful thing to know and requires some complex syntax to achieve it.

@edbennett
Copy link

@edbennett edbennett commented Jul 24, 2019

One of our students yesterday pointed out that it could be done via SELECT group_concat(personal || ' ' || family, ' ') FROM (SELECT * from Person ORDER BY family);, but we don't currently teach subqueries anywhere (except one being used in the solution to the "Averaging with NULL" challenge, which itself is rather confusing)

@edbennett
Copy link

@edbennett edbennett commented Jul 24, 2019

Oh, this was already discussed in #255

colinsauze added a commit to colinsauze/sql-novice-survey that referenced this issue Jul 24, 2019
Removes the requirement to order the results in final aggregation exercise on concatenating. There was no solution for this exercise and solving it required using sub queries which haven't been discussed until now. 

I've simplified it to no need the results to be ordered, but instead to require a colon character as a separator. This way there's still a reason to use group_concat. 

This has been previously discussed in bugs swcarpentry#158, swcarpentry#255 and swcarpentry#288. A previous solution was proposed and then retracted in pull request swcarpentry#210.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants