All In One Script
MENU

MySQL Query GROUP BY day / month / year

by 5:00:00 AM
undefined
MySQL Query GROUP BY day / month / year Is it possible I make a simple query to count how many records I have in a determined period of time like a Year, month or day, having a TIMESTAMP field, like: SELECT COUNT(id) FROM stats WHERE record_date.YEAR = 2009 GROUP BY record_date.YEAR Or even: SELECT COUNT(id) FROM stats GROUP BY record_date.YEAR, record_date.MONTH To have a monthly statistic. Thanks! Answer: GROUP BY YEAR(record_date), MONTH(record_date) Check out the date and time functions in MySQL. http://stackoverflow.com/questions/508791/mysql-query-group-by-day-month-year/508806#508806

SQL Group By with an Order By

by 4:22:00 AM
undefined
SQL Group By with an Order By I have a table of tags and want to get the highest count tags from the list. Sample data looks like this id (1) tag ('night') id (2) tag ('awesome') id (3) tag ('night') using SELECT COUNT(*), `Tag` from `images-tags` GROUP BY `Tag` gets me back the data I'm looking for perfectly. However, I would like to organize it, so that the highest tag counts are first, and limit it to only send me the first

Instagram