-- Successful requests:
 select count(hitID) AS "Successful requests"
 from Hit
 where CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
;

 select count(hitID) AS "Successful requests last week"
 from Hit
 where hitdatetime > 'now'::datetime-'1 week'::interval
 and hitdatetime < 'now'::datetime
 and CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
;

-- Average successful requests:
 select trunc(count(hitid)/
             extract(day from 
                     date_trunc('day',max(hitdatetime)-min(hitdatetime))))
        AS "Average successful requests per day last week"
 from Hit
 where hitdatetime > 'now'::datetime-'1 week'::interval
 and hitdatetime < 'now'::datetime
 and CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
;

 select trunc(count(hitid)/
             extract(day from 
                     date_trunc('day',max(hitdatetime)-min(hitdatetime))))
        AS "Average successful requests per day"
 from Hit
 where
 CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
;

-- Successful requests for pages:
 select count(hitID) AS "Successful page requests"
 from Hit
 where CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
 and MimetypeID = (select MimetypeID from MimeType
     where Mimetypetext='text/html')
;

 select count(hitID) AS "Successful page requests last week"
 from Hit
 where hitdatetime > 'now'::datetime-'1 week'::interval
 and hitdatetime < 'now'::datetime
 and CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
 and MimetypeID = (select MimetypeID from MimeType
     where Mimetypetext='text/html')
;

-- Successful requests for pages per day:
 select trunc(count(hitid)/
             extract(day from 
                     date_trunc('day',max(hitdatetime)-min(hitdatetime))))
        AS "Average successful page requests per day"
 from Hit
 where CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
 and MimetypeID = (select MimetypeID from MimeType
     where Mimetypetext='text/html')
;

 select trunc(count(hitid)/
             extract(day from 
                     date_trunc('day',max(hitdatetime)-min(hitdatetime))))
        AS "Average successful page requests per day last week"
 from Hit
 where hitdatetime > 'now'::datetime-'1 week'::interval
 and hitdatetime < 'now'::datetime
 and CustomerID = (select customerid from customer 
     where Customertext='odder-campingcenter.dk')
 and (Status = 200 or Status = 206)
 and MimetypeID = (select MimetypeID from MimeType
     where Mimetypetext='text/html')
;


