Once I ran into a problem where I had to get the list of users who has gmail.com contacts along with the contacts sip addresses.
Following is the SQL query I used for the same.
We can use this to find the same information for any domain by just replacing gmail.com with the domain name.
select (select UserAtHost from dbo.Resource Where ResourceId = c.OwnerId) [User] ,r.UserAtHost [Gmail Contact]
from dbo.Contact as c
inner join dbo.Resource as r on r.ResourceId = c.BuddyId
Where r.UserAtHost like 'Nemail@example.com'