TheOdinProject / curriculum

The open curriculum for learning web development
https://www.theodinproject.com/
Other
10.1k stars 13.53k forks source link

Databases and SQL: Suggested Command in W3 Schools Editor Causes Error #28204

Closed columk1 closed 3 months ago

columk1 commented 5 months ago

Checks

Describe your suggestion

Issue

The section on aggregate functions contains the following suggestion:

See W3 Schools’ article and play around with the SQL in the window (try deleting the GROUP BY line) for an interactive visual.

Deleting this line in the linked editor changes the query from:

SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country;

To:

SELECT COUNT(CustomerID), Country FROM Customers;

When the new query is run, it causes the editor to throw an error:

Error in SQL: You tried to execute a query that does not include the specified expression 'Country' as part of an aggregate function.

Suggestion

Remove the text in parentheses.

play around with the SQL in the window (try deleting the GROUP BY line) for an interactive visual.

Alternatively, the lesson should be more specific in what it wants students to learn by deleting this line. If the goal is to show students the error then it should come with an explanation that SQL needs to know how to group the rows for non-aggregated columns. The syntax in the current error message isn't enough for someone new to SQL.

Path

Ruby / Rails

Lesson Url

https://www.theodinproject.com/lessons/databases-databases-and-sql

(Optional) Discord Name

columk

(Optional) Additional Comments

No response

github-actions[bot] commented 4 months ago

This issue is stale because it has had no activity for the last 30 days.

DrantDumani commented 3 months ago

Bumping this issue as I agree that the error message may not be enough for someone who is brand new to sequel. Plus, it can also be confusing to explicitly follow the directions the lesson gives you, only to run into an error.

JoshDevHub commented 3 months ago

Oh wow yeah. I think you can just get rid of that note about deleting the GROUP BY clause. It's ambiguous what the intent is, and I don't think it's all that important to go through the error that exists without having it present.

Since you indicated you'd like to work on it, I'm glad to assign you @columk1