Hi guys,
I'm punching way above my weight for mySQL Queries and syntax right now. I could do with some help achieving the following:-
I have a metrics/analytics table with country of visit in a row. I have the following query:-
SELECT `country`, COUNT(`ip`) AS `cViews` FROM `metrics` WHERE `projID` = 'projID' AND `country` != 'XX' AND `when` BETWEEN '$dateFrom' AND '$dateTo' GROUP by country
Note; when
is a timestamp field.
Which gets the number of visits per country from a given timeframe. Fine. Dandy, one might say.
What I now need, is to display a table (forget the displaying, I need help simply with the query) which can group the visits into each month under a title of that month. I.e. Country/Visits for each month. Probably specified with a timestamp of BETWEEN '2009-06-00' AND '2009-06-30' with those dates declared in variables at the top.
So I need to get from multiples of:-
`id` `ip` `country` `etc`
1 24.124 uk thisthat
To:-
`country` `Jan` `Feb`
UK 44 77
etc.
Now, I've had help here before which has declared names AS, but the potential complexity of this query is frigtening me and I'm not quite sure how to do it, even as nested select queries.
Any advice or pointing in the right direction gratefully received.