Finding the total sum of salary for person who worked at least two years
Try this:

SELECT name AS [Name of Employee], 
    SUM(salary) AS [Salary Earned] 
FROM Employee 
GROUP BY name
HAVING MAX(year) &gt; 1;


This will exclude those records whose maximum "year" having is 1, basically those who have not been employed for more than 1 year.