Re: [SQL] how many times - Mailing list pgsql-sql

From Campbell, Lance
Subject Re: [SQL] how many times
Date
Msg-id B75CD08C73BD3543B97E4EF3964B7D7047D3FA88@CITESMBX1.ad.uillinois.edu
Whole thread Raw
In response to Re: [SQL] how many times  (Rob Sargent <robjsargent@gmail.com>)
List pgsql-sql

I appreciate your response but I don’t see how to apply this to five minute time frames?

 

Thanks,

 

Lance

 

From: pgsql-sql-owner@postgresql.org [mailto:pgsql-sql-owner@postgresql.org] On Behalf Of Rob Sargent
Sent: Wednesday, August 23, 2017 1:16 PM
To: pgsql-sql@postgresql.org
Subject: Re: [SQL] how many times

 

 

 

On 08/23/2017 12:03 PM, Campbell, Lance 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

window functions are your friends
https://www.postgresql.org/docs/current/static/functions-window.html

pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: [SQL] how many times
Next
From: "David G. Johnston"
Date:
Subject: Re: [SQL] how many times