Home  >  Article  >  Database  >  mysql-如何获取一年里每个月的记录总数,要求不管该月有没有数据都要显示,没有的显示为0?

mysql-如何获取一年里每个月的记录总数,要求不管该月有没有数据都要显示,没有的显示为0?

WBOY
WBOYOriginal
2016-06-06 09:42:191923browse

mysql

假如我有个数据表,里面只有“2007-05-29”的一条数据,
我希望得到的结果是
月份 数据
1 0
2 0
3 0
4 0
5 1
6 0

7 0
8 0
9 0
10 0
11 0
12 0

有个主键商品id,销售日期date,,,mysql的数据库,有劳各位了~~~

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn