select RU.UrlText, count(hitid)
 from Hit H, URL RU
 where
  CustomerID = (select customerid from customer
     where Customertext='pi.dk')
  and H.RefererHostID=(select hostid from Host
     where HostText='www.google.com')
  and hitdatetime < 'now'::timestamp
  and hitdatetime > 'now'::timestamp-'1 year'::interval
  and H.RefererUrlID = RU.UrlID
group by urltext;

select customerid
from hit
where
  hit.refererhostid = (select hostid from Host
     where HostText='www.google.com')
