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.
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.
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