
select dato,count(hitid) from
(select date_trunc('day',hitdatetime) as dato,hitid
 from Hit
 where
  CustomerID = (select customerid from customer
     where Customertext='pi.dk')
  and hitdatetime < 'now'::timestamp
  and hitdatetime > 'now'::timestamp-'1 year'::interval
) as d
 group by dato;

