SQL query

Soldato
Joined
29 Aug 2010
Posts
7,907
Location
Cornwall
Hi,

I was wondering if anyone may be able to help me out.
I'm wondering if there is a way to count the number of rows on a table, grouped by week, based on a timestamp field?

So basically 3rd - 7th June are grouped (Week 1), 10th - 14th grouped (Week 2), etc.

I'm struggling with this one, I need to do the same for days but have found a few suggestions that may help with that.

As it may be important, the Database is a Postgres 9.1 DB.

Thanks.
 
Soldato
Joined
27 Mar 2003
Posts
2,710
oh just thought. If you are spanning years then it is probably worth grouping by years first then by week

eg
DatePart(year,<your timestamp field>), DatePart(wk, <your timestamp field>)

Hope this helps
 
Back
Top Bottom