maybe left join ( select UD.userID, count(*) as Friends_PhotosApprovedCount from tblUserDetails UD inner join tblFriends F on UD.userID = F.userID inner join tblextraphotos E on E.userID = F.friendID and E.photoDate > dateadd(dd, -1, getdate()) group by UD.userID having count(*) > 0 ) e on a.userID = e.userID
==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy.