Give this a try. Note I did not test the query.select u.userID, u.nameOnline, u.lastLoggedIn, u.emailAddress, isnull(a.IMCount, 0) as IMCount, isnull(b.MailCount, 0) as MailCountfrom tblUserDetails u left join ( select UD.userID, count(*) as IMCount from tblUserDetails UD inner join tblInstantMessage IM on IM.messageToID = UD.userID and IM.checked = 0 and IM.Date < UD.lastLoggedIN and IM.Date > dateadd(day, -1, getdate()) group by UD.userID having count(*) > 0 ) a on u.userID = a.userID left join ( select UD.userID, count(*) as MailCount from tblUserDetails UD inner join tblMessage M on M.messageTo = UD.userID and M.checked = 0 and M.Date < UD.lastLoggedIN and M.Date > dateadd(day, -1, getdate()) group by UD.userID having count(*) > 0 ) b on a.userID = b.userIDwhere a.IMCount is not nullor b.MailCount is not null
KH