Re: Subtracting months in MySQL

From: Date: Thu, 22 May 2003 08:44:19 +0000
Subject: Re: Subtracting months in MySQL
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-27956@lists.php.net to get a copy of this message
Hi John, That did the trick, and much simpler than I thought it had to be! Thanks. -Lisi At 09:48 AM 5/20/03 -0400, CPT John W. Holmes wrote:
I have a table that stores a daily summary of page hits. I need to be able to summarize this data by month, which I've done with the following query: SELECT
    MONTHNAME(date) as month,
    YEAR(date) as year,
    SUM(count) as count
FROM pagehits WHERE date > CURDATE() - INTERVAL 12 MONTH GROUP BY
    YEAR(date),
    MONTHNAME(date)
ORDER BY
    YEAR(date),
    MONTH(date)
I then need to limit this to the previous 12 months. ---John Holmes...


« previous php.db (#27956) next »