Last answered:

02 Dec 2023

Posted on:

28 Aug 2023

0

Resolved: I am getting an error when submitting the 2 codes in the exercise

5 answers ( 2 marked as helpful)
Posted on:

12 Sept 2023

3

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.

Instructor
Posted on:

13 Sept 2023

0

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

Posted on:

18 Oct 2023

1

Hello, please why does the code provided by Muhammad need to be executed first in his workbench?

Posted on:

13 Nov 2023

1

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.

Posted on:

02 Dec 2023

0

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?


Submit an answer