English 中文(简体)
PHP /MYSQL按月和年列出各行
原标题:PHP / MYSQL list rows by month and year

我与Sandql一起做了活动,在数据库中添加以下领域的活动:id、所有权、内容、日期(时间: YYYY-MM-DD 00:00:00)

我想按年/月分类我的记录,并计算结果。

Example :

www.un.org/Depts/DGACM/index_french.htm

  • Event1 title1 content1 date1
  • Event2 title2 content2 date2
  • Event2 title2 content2 date2

<DECEMBER 2011: 2 results

  • Event1 title1 content1 date1
  • Event2 title2 content2 date2

......

I try differents ways using group by but nothing conclusive I appreciate your time and i wait for feedback. Thanks in advance.

我尝试了这部法律。

SELECT id, title, content, date, EXTRACT( YEAR
FROM date ) ANNEE, EXTRACT( 
MONTH FROM date ) MOIS, COUNT(*) AS mySum
FROM plaquerecherchee
GROUP BY ANNEE, MOIS
ORDER BY ANNEE, MOIS

仅有一个月结果.........

问题回答

引言

select Event1, title1, content1, MONTH(date),count(1) from yourtable
group by  Event1, title1, content1, MONTH(date)
SELECT id,title,content,date,count(*) as mySum from TABLENAME
GROUP BY date.MONTH, date.YEAR
ORDER BY date.YEAR,date.MONTH




相关问题
Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...

iPhone Date Picker rolls over to 2010 on December 27th?

So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...

Convert date Python

I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?

specifying date format when using $form->inputs() in CakePHP

I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...

NSDateFormat, super simple! Where am I screwing up?

Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...

sqlite writing a date into an email

I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...

热门标签