RE: [PHP] Bug in SQL can you help?

From: Date: Tue, 09 Jul 2002 11:29:06 +0000
Subject: RE: [PHP] Bug in SQL can you help?
Groups: php.general 
Request: Send a blank email to php-general+get-106337@lists.php.net to get a copy of this message
> -----Original Message----- > From: JJ Harrison [mailto:webmaster@tececo.com] > Sent: Tuesday, July 09, 2002 12:33 PM > To: php-general@lists.php.net > Subject: [PHP] Bug in SQL can you help? > > > Here is my SQL(used in a PHP script so this isn't ot) PHP-script or not, it's still an SQL-query, right? I'll give it a shot anyway... > SELECT > extract(year FROM time), > extract(month FROM time), > count(*) as monthly_views, > time > FROM > tececo_stats > group by > extract(year FROM time), > extract(month FROM time) > order by > monthly_views desc > limit 1 > > the problem is that is counts the number of rows in the whole > thing not the > echoed row. How can I get it count the best days only? SELECT CONCAT(YEAR(time), MONTH(time)) AS my_period, MAX(COUNT(*)) AS monthly_views FROM tececo_stats GROUP BY my_period /Joakim

« previous php.general (#106337) next »