The easiest method is to use a subquery as a JOIN in your <a href="http://itknowledgeexchange.techtarget.com/sql-server/back-to-basics-the-select-statement/">SELECT</a> Statement.
Something like this.
<pre>SELECT Employee.*
FROM Employee
JOIN (SELECT DepartmentId,
AVG(Salary) Salary
FROM Employee
GROUP By DepartmentId) SalaryInfo ON Employee.DepartmentId = SalaryInfo.DepartmentId
AND Employee.Salary > SalaryInfo.Salary</pre>
Last Wiki Answer Submitted: July 18, 2008 5:41 pm by Denny Cherry64,520 pts.
All Answer Wiki Contributors: Denny Cherry64,520 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
Check out my SQL Server blog “SQL Server with Mr Denny” for more SQL Server information.