i have a similar question. i have two tables where table 'courses'
hasMany 'students' and 'students' belongs to 'courses'. I want to be
able to have a list of all the courses and count how many students
there are (ex: english - 20 students, math - 35 students). I've been
searching all over...Count
> SELECT DISTINCT YEAR(date) AS year, MONTH(date) AS month, count(id) AS
> numb
> FROM articles
> GROUP BY YEAR(date), MONTH(date)
> ORDER BY date DESC
>
> This way you get the results grouped by year, with each month and the
> number of articles per month. Bam.
thanks, that works perfectly
jon
You could do a query like this:
SELECT DISTINCT YEAR(date) AS year, MONTH(date) AS month, count(id) AS
numb
FROM articles
GROUP BY YEAR(date), MONTH(date)
ORDER BY date DESC
This way you get the results grouped by year, with each month and the
number of articles per month. Bam.
On Mar 8, 7:25
something like that?
function getRange() {
$q = "
SELECT date_format(`date` , '%M %Y' ) AS month_year
FROM posts
WHERE active = '1'
GROUP BY date_format(`date` , '%m-%Y' )
LIMIT 0, 12";
$result = $this->query($q);
return $res
hi,
we have a blog app [http://www.webmarketingblog.co.uk/blog] and in the
sidebar we want to have a list of months that have posts, eg:
Febuary 2007
March 2007
... etc etc
any pointers on querying my model so I can get a list of months with
active posts?
many thanks,
Jon
--
jon bennett
t