Tag: Filter

Broken Left Join

Here is a simple example of a LEFT JOIN that returns the sales stats for all employees under 21. SELECT e.Name, COUNT(s.SaleId) AS Sales, MAX(s.DateOfSale) AS LatestSale FROM Employees e LEFT JOIN Sales s ON e.EmployeeId = s.EmployeeId WHERE e.Age < 21 GROUP BY e.Name This will return all employees under the age of 21 […]

Sign Up

James Anderson SQL Server DBA

Hi, I'm James Anderson. When I'm not blogging about SQL Server, I do this.

The SQL People

DBA Stackexchange Profile