Resolved: I am getting an error when submitting the 2 codes in the exercise
Please, execute the following command:
set @@global.sql_mode := replace(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', '');
Then, you have to restart the Workbench in order to save the new settings.
Copied.
Hi Fatma!
Thanks for reaching out.
Please, use the code provided by Muhammad. Then, you have to restart the Workbench in order to save the new settings.
Hope this helps.
Best,
Tsvetelin
Hello, please why does the code provided by Muhammad need to be executed first in his workbench?
The issue with your query is that you're using the AVG function in the SELECT clause without properly grouping the other columns. When you use an aggregate function like AVG with a GROUP BY clause, you should only include columns in the SELECT clause that are either part of the grouping or used with an aggregate function.
Thanks for providing the solution for the error. The first code gives 807 rows, and the second gives 101 rows, as you indicated. Below is the code
SELECT
*, AVG(salary)
FROM
salaries
WHERE
salary > '120000'
GROUP BY emp_no
ORDER BY emp_no
Any reason why?