1SELECT FirstName,
2 LastName,
3 IsNull((
4 SELECT COUNT(UP1.EmailAddress) AS HasEmail
5 From dbo.UserProfiles AS UP1
6 WHERE (NOT (UP1.EmailAddress IS NULL))
7 AND (CreatedBy = dbo.UserProfiles.UserID)
8 GROUP BY CreatedBy), 0) AS EmailEnteredCount
9FROM dbo.UserProfiles
10WHERE (IsStaff = 1)