在 mysql 中显示月份名称而不是月份编号

display month name instead of month number in mysql

编写查询以显示月份名称和 2013 年每个月安排的事件数,按月份排序。给月份名称起一个别名 month_name,给计划的事件数起一个别名 number_of_events。月份名称必须显示为 January、February ... 我尝试了以下查询但未执行:

select convert(varchar(10),month,date) as month_name, count(*) as number_of_events
from event where year(date)=2013 group by date order by date ;

table 姓名:

event

列:

id           bigint(20)    primary key
date         datetime
description  varchar(255)
invitation   varchar(255)
name         varchar(255)
organiser_id bigint(20)

您应该使用 MONTHNAME(date) - 像这样:

select MONTHNAME(date),COUNT(*) from event where year(date)=2013 group by MONTH(date)