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

Broken exercise requiring a subquery #255

Open
Denubis opened this issue Jul 6, 2018 · 3 comments
Open

Broken exercise requiring a subquery #255

Denubis opened this issue Jul 6, 2018 · 3 comments

Comments

@Denubis
Copy link
Contributor

@Denubis Denubis commented Jul 6, 2018

Hi folks. Just noting this here because it was a major trap in the lesson.

In 06-agg,

The function group_concat(field, separator) concatenates all the values in a field using the specified separator character (or ‘,’ if the separator isn’t specified). Use this to produce a one-line list of scientists’ names, such as:

William Dyer, Frank Pabodie, Anderson Lake, Valentina Roerich, Frank Danforth
Can you find a way to order the list by surname?

is broken. The answer requires a subquery:

SELECT group_concat(name, ', ') FROM (select personal||' '||family as name from person order by family);

And we never teach the idea of subqueries in the lesson. I riffed on this because it helped flow into the VIEWs needed by my edits to the capstone, but I recommend that this exercise be cut, because it's a trap for unwary instructors.

(Basically, because order by runs on the output rows, not the input rows, we need to sort the input data before we hit the aggregation step.)

Just dropping in post-workshop feedback, because I don't have time to edit this in properly to the lesson, and I think it'd introduce way too much cognitive load.

@remram44

This comment was marked as off-topic.

@remram44
Copy link
Contributor

@remram44 remram44 commented Jul 6, 2018

Oh I see, a subquery is required IF you want to order. Yes, that is unfortunate. Should the question be tweaked to producing the list out of order?

@Denubis
Copy link
Contributor Author

@Denubis Denubis commented Jul 6, 2018

Hi Remi,

I think having summative exercises here is a good thing. And this teaches pivoting with group_concat. If it's just "Hey I can use more aggregation methods, and this one is called group_concat" then I think it works well. So both routes work. Maybe copy this one to one of the final exercises with discussion of subqueries in a todo and leave a non-ordered version here?

donalus pushed a commit to donalus/sql-novice-survey that referenced this issue Oct 11, 2018
lesson_check: switch to argparse
@ErinBecker ErinBecker added this to the June 2019 Release milestone May 14, 2019
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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants