05 Oct 2022

Posted on:

08 Nov 2021

0

# Average salary per year?

I don't think the HAVING solution calculates the average salary per year. I believe the query would need to take into account the start/end dates (maybe take the sum of salaries divided by the difference in dates). Many end dates are "9999-01-01". These might be the contracts mentioned in the solution, but it's not really clear. In any case, those end dates don't make sense, so the data provided is unreliable in some sense when doing calculations based on end dates.

Instructor
Posted on:

16 Dec 2021

1

Hi Luke!

Thanks for reaching out.

The average salary is calculated when you sum all salaries of the current employee and divide by the number of records for this particular employee. If an employee has 10 different periods of work we sum up these 10 salaries and divide the result by 10. If this calculation is bigger than 120 000\$ then it is included in the result set.  When using WHERE instead of HAVING, the output is larger because in the output we include individual contracts higher than \$120,000 per year.

Hope this helps.
Best,
Martin

Posted on:

30 Sept 2022

0

so, the same employee can be repeated more than one time
when the first and last name is equal its consider as one salary for this person and when the name is repeated again then it would be the second salary for this person.

after that, we sum them and divide = the normal way to get average =SUM/COUNT

Instructor
Posted on:

05 Oct 2022

0

Hi Peter!
Thanks for reaching out.

Thanks for sharing this piece of information with the Community!

Best,
Tsvetelin