-
-
Save egi/1370233 to your computer and use it in GitHub Desktop.
Need help with a MySQL query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have the following query: | |
SELECT COUNT( DISTINCT ( brand.id )), MONTH(u.created_at) | |
FROM brand | |
LEFT JOIN brand_admin_group bag ON brand.id = bag.brand_id | |
LEFT JOIN brand_admin_group_membership bagm ON bag.id = bagm.brand_admin_group_id | |
LEFT JOIN user u ON bagm.user_id = u.id | |
GROUP BY MONTH(u.created_at) | |
Results look like this: | |
23,"2011-01-04 16:55:51" | |
24,"2011-01-04 17:19:46" | |
25,"0000-00-00 00:00:00" | |
26,"2011-01-08 17:25:18" | |
27,"2011-01-08 22:34:55" | |
28,"2011-01-10 07:33:59" | |
29,"2011-01-12 08:06:30" | |
30,"2011-01-12 08:54:09" | |
31,"2011-01-12 09:12:20" | |
32,"2011-01-12 09:18:42" | |
33,"2011-01-12 09:19:58" | |
34,"2011-01-12 09:20:15" | |
Now, what I need to do is come up with a query that counts the number of brands grouped by the month of creation. u.created_at is a datetime field (ie 2011-02-08 19:13:58). | |
Any help would be appreciated |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment