curriculum icon indicating copy to clipboard operation
curriculum copied to clipboard

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

Open columk1 opened this issue 1 year ago • 0 comments

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

columk1 avatar Jun 12 '24 10:06 columk1