The average that a NULL salary ruins

SQLMedium10 min

Your task

Return each department with its average salary as avg_salary, rounded to the nearest whole number, counting only employees whose salary is recorded. Also return department.

One employee has no salary. Decide what that means before you write the query.

Tables

department
idINTEGERnameTEXT
1Engineering
2Sales
3Design
4Research
employee
idINTEGERnameTEXTsalaryINTEGERdepartment_idINTEGERmanager_idINTEGERhired_onTEXT
1Ada1800001NULL2021-03-01
2Grace165000112022-06-15
3Linus140000112023-01-09
4Mel1200002NULL2020-11-20
5Kay120000242023-04-02
6IvanNULL242024-02-17
More rows not shown