
/*
 Visits counted as "entering the web-site" from externals sites
 or keying in URL.
*/

--explain
 select count(hitID) AS "Visits one day web-shoppen.dk"
 from Hit
 where hitdatetime > '2000-04-17 00:00:00'
 and hitdatetime < '2000-04-18 00:00:00'
 and hostID != RefererHostID
 and CustomerID = (select customerid from customer where Customertext='web-shoppen.dk')
;

--explain
 select H.hostText, ipid, rHost.HostText
 from Hit, Host H, Host rHost
 where hitdatetime > '2000-04-17 00:00:00'
 and Hit.HostID=H.HostID
 and Hit.RefererHostID=rHost.HostID
 and hitdatetime < '2000-04-18 00:00:00'
 and Hit.hostID != RefererHostID
 and CustomerID = (select customerid from customer where Customertext='web-shoppen.dk')
 order by Hit.hostID, ipid, RefererHostID
;
