Last answered:

18 Apr 2022

Posted on:

22 Nov 2021

0

SELECT EMP_NO IN STEAD OF SELECT*

I replaced * by emp_no since we are only interested in employees no but not in all of their information, is it right this way???

select emp_no, avg(salary) from salaries
group by emp_no
having avg(salary)>120000;

5 answers ( 0 marked as helpful)
Instructor
Posted on:

16 Dec 2021

1

Hi Asmaa!

Yes, this is also correct. Bravo!

Hope this helps.
Best,
Tsvetelin

Posted on:

05 Mar 2022

3

I receive an error when using:

SELECT
    *, AVG(salary)
FROM
    salaries
GROUP BY emp_no
HAVING AVG(salary) > 120000;

when I change the * for emp_no it runs fine.

Instructor
Posted on:

16 Mar 2022

0

Hi Sandra!
Thanks for reaching out.

Could you please share with us a screenshot of the whole error message you've encountered? This can help us assist you better. Thank you.

Looking forward to your answer.
Best,
Tsvetelin

Posted on:

01 Apr 2022

0

SELECT      *, AVG(salary) FROM     salaries GROUP BY emp_no HAVING AVG(salary) > 120000 LIMIT 0, 1000

Error Code: 1055. Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'employees.salaries.salary' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

Instructor
Posted on:

18 Apr 2022

1

Hi Chun!
Thanks for reaching out.
Please, execute the following command:
set @@global.sql_mode := replace(@@global.sql_mode, 'ONLY_FULL_GROUP_BY', '');
Then restart your Workbench. It should fix the issue.

Hope this helps.
Best,
Tsvetelin

Submit an answer