How to group by year and month in My SQLAsk a question
I have a table user_games with a date field created_at. So I’m trying to group records by given year and month and find the number of records. I use MySQL. So this is my query. Seems it is working but I am not sure that it is the correct way
SELECT concat(year(ug.created_at), '-' ,month(ug.created_at)), ug.user_id, count(*) FROM user_games ug GROUP BY concat(year(ug.start_date), '-' ,month(ug.start_date));
Is there better approche ?
- 0C++ book guide and list
- 0undefined behavior and sequence points
- 1main function signature in C and C++
- 0What is the copy-and-swap idiom
- 0Pointless if-else and do-while in
- 0Difference between copy initialization and direct initialization
- 0C++: difference between 'struct' and 'typedef struct'
- 0public, protected and private inheritance
- 0Meanings of zero-, value- and default-initialization
- 0How do malloc() and free() work?
- 0What are external and internal linkage