Neil, I would start with something like this, assuming the date column is called "d":
SELECT <count, or sum, or whatever aggregate function> FROM <table> GROUP BY d - INTERVAL DAYOFWEEK(d) DAY; - Baron On Thu, Apr 29, 2010 at 8:12 AM, Tompkins Neil <neil.tompk...@googlemail.com> wrote: > Hi > > We need to produce a query to return the total number of user visits between > two date ranges that span over two year e.g from 2009-04-29 to 2010-04-29. > My question is how can I compute the totals for each week within a query ? > for example > > 2009-04-29 to 2009-05-06 100 visits > 2009-05-07 to 2009-05-14 250 visits etc > > Cheers > Neil > -- Baron Schwartz Percona Inc <http://www.percona.com/> Consulting, Training, Support & Services for MySQL -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org