problem with selecting correct values from database
1) 

select TOP (1) ename,salary from Employee where classification='4'
order by salary desc


2)

 select did,dname from Department
 where exists
 (select 1  from Employee 
 group by did,classification
 having count(*) = 2
 and classification = '3' and Department.did = Employee.did)


3)

 with cte as(
 select did,byear,budget,LAG(byear) OVER (partition by did order by budget) as preceeding, 
 LEAD(byear) OVER (partition by did order by budget) as next from budget
 where budget &lt; 70000 
 )
 select distinct did,coalesce(preceeding,byear) as FirstYear,coalesce(next,byear) as NextYear from cte where cte.byear = preceeding + 1 or cte.byear = next - 1


Hope this helps!