Jump to content

mySQL GROUP BY


Grabeorama

Recommended Posts

I use this query to group rows in a table by their day in the current year:

$date	= strtotime(date("M  j, H:i:s"));		$sql	= "SELECT *, DAYOFYEAR(FROM_UNIXTIME(date)) AS mydate , COUNT(FROM_UNIXTIME(date)) AS tot FROM gblog_stats WHERE FROM_UNIXTIME(date) BETWEEN DATE_SUB( FROM_UNIXTIME(". $date .") ,INTERVAL 30 DAY )							AND FROM_UNIXTIME(". $date .") GROUP BY mydate";

The query works perfectly but as an output I may get this:[day of year] - [number of rows]11 - 312 - 815 - 416 - 519 - 3As you can see, the dates that have no row do not display, is there a way in which I could this:[day of year] - [number of rows]11 - 312 - 813 - 014 - 015 - 416 - 517 - 018 - 019 - 3Thanks for any help :)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...