title: Why there is a sort task in execution plan
body: <p>When i execute the following query with execution plan.I could see that 'sort' is most costlist task.But i am not using any sort option in my query.Why it is happening?There is a nested loop join task exist before select.Also please let me know about merge join,hash join and nested loop join.</p>
  
  <p><img src="https://i.stack.imgur.com/7HIYd.png" alt="enter image description here"></p>
  
  <pre><code>select
  Ename from dbo.Employee e
  where 
  Salary&gt;(
  select AVG(Salary) from dbo.Employee where 
  DeptId=e.DeptId 
  group by DeptId)
  </code></pre>