Re: how many times

From: "Campbell, Lance" <lance(at)illinois(dot)edu>
To: Michael Moore <michaeljmoore(at)gmail(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: how many times
Date: 2017-08-24 14:46:27
Message-ID: B75CD08C73BD3543B97E4EF3964B7D7047D42E56@CITESMBX1.ad.uillinois.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Thanks.

From: Michael Moore [mailto:michaeljmoore(at)gmail(dot)com]
Sent: Wednesday, August 23, 2017 4:19 PM
To: Campbell, Lance <lance(at)illinois(dot)edu>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] how many times

something like this.
select
sum (case when buc = 1 then 1 else 0 end) _1_8_sec,
sum (case when buc = 2 then 1 else 0 end) _2_8_sec,
sum (case when buc = 3 then 1 else 0 end) _3_8_sec,
sum (case when buc = 4 then 1 else 0 end) _4_8_sec,
sum (case when buc = 5 then 1 else 0 end) _5_8_sec,
sum (case when buc = 6 then 1 else 0 end) _6_8_sec,
sum (case when buc = 7 then 1 else 0 end) _7_8_sec,
sum (case when buc = 8 then 1 else 0 end) _1_sec,
sum (case when buc = 9 then 1 else 0 end) _8_8_sec,
sum (case when buc = 10 then 1 else 0 end) _10_8_sec,
sum (case when buc = 11 then 1 else 0 end) _11_8_sec,
sum (case when buc = 12 then 1 else 0 end) _12_8_sec,
count(*) cnt
from
(select width_bucket( temp_time, 0, 1500 , 11) buc from mikes_debug_log_vals2 where temp_time is not null) x

On Wed, Aug 23, 2017 at 11:03 AM, Campbell, Lance <lance(at)illinois(dot)edu<mailto:lance(at)illinois(dot)edu>> wrote:
I am not for sure how to do the below. I was hoping someone could share their thoughts.

Assume I have a table called T1. It contains a single filed called “viewed” that is of type timestamp.

Every time someone views a particular web page we insert the current timestamp into T1.

Now I need to ask this business question:

On average in any consecutive five minute time frame how many times is the web page viewed?

Thanks,

Lance

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sebastien FLAESCH 2017-08-24 15:21:55 Determining the DATE format with libpq
Previous Message Michael Moore 2017-08-23 21:19:03 Re: how many times