开发者

what is the best way to call a group of results from mySQL by quarter?

I am looking to开发者_运维技巧 order a set of results of a mySQL data by quarter. They have data fields, so I am wondering if I should be doing this in PHP or in the query itself?


if you have date field in the db use it to group with it,

like:

group by QUARTER(date)

of course if you want to take in account the years also

use

group by YEAR(date) , QUARTER(date)


You can use GROUP BY Clause in mysql query and return results as -

group by Quarter(date)

Where Quarter is a pre-defined function in mysql.


I would do it in the DB - look up the MySQL function Quarter(Date).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜