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

From Rob Sargent
Subject Re: [SQL] how many times
Date
Msg-id 864a1386-2c98-5060-1a72-d663671af917@gmail.com
Whole thread Raw
In response to [SQL] how many times  ("Campbell, Lance" <lance@illinois.edu>)
Responses Re: [SQL] how many times  ("Campbell, Lance" <lance@illinois.edu>)
List pgsql-sql



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: "Campbell, Lance"
Date:
Subject: [SQL] how many times
Next
From: "Campbell, Lance"
Date:
Subject: Re: [SQL] how many times