I have made a query which shows all hits recorded for a particular region. It goes something like this:
Unique Visits by Region
SELECT
r.field_region_for_real_value as region, Count(*) as count
FROM
login_activity l, users u, field_data_field_region_for_real r
where l.uid = u.uid AND u.uid = r.entity_id
Group by r.field_region_for_real_value
The results of this are as follows:
region | count
----------------------
Asia 23
EEMA 14
Latin America 73
North America 61
Western Europe 47
But now what I am trying to do is to change the way this data is represented. I am hoping that instead of grouped by region
, it is grouped by month. Within the month, I am hoping to have all values of each region that have a data falling in that month.
For example, here is the result I am hoping to achieve:
month | Asia | EEMA | Latin America | North America | Western Europe
----------------------------------------------------------------------------------------------------
Jan 23 43 23 43 53
Feb 63 3 13 39 18
Mar 23 39 42 29 17
Apr 49 56 50 64 98
May 63 3 13 39 18
Jun 21 92 15 23 19
Jul 49 56 50 64 98
Aug 63 3 13 39 18
Sep 63 3 13 39 18
Oct 23 39 42 29 17
Nov 23 43 23 43 53
Dec 21 92 15 23 19
The date which needs to be processed comes from the table login_activity
. The fields of the table are as follows:
aid int . (Unique ID)
uid int
hostname varchar
timestamp int (Date)