I am having trouble writing a query on a mysql table of user activity that will give me a breakdown of how active our users are. The table structure is like so:
CREATE TABLE IF NOT EXISTS `ca_activity` (
`id` bigint(20) NOT NULL auto_increment,
`user_id` bigint(20) default NULL,
`activity_type` varchar(50) collate utf8_unicode_ci default NULL,
`activity_source` varchar(255) collate utf8_unicode_ci default NULL,
`created` timestamp NULL default NULL,
`updated` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2037 ;
The result I'm looking for is the number of users who performed each number of activities, grouped by the number of activities. For example 12330 users performed 1 activity, 9032 performed 2 activities and so on. I'm completely stuck on this so any hints would be appreciated.