选择过去13个月的名称诱导当前月份

时间:2017-11-07 20:58:19

标签: mysql

专家,

最后13个月的最佳方式是引导当月。在表格中,我记录了2014年以来的每个月。

注意:日期格式为 - 2016-01-15,每个月在表格中有多条记录。

如下所示

   SELECT MONTHNAME(start_date) as month_name 
   FROM purchase_order_entry_reports  
   WHERE start_date (needs to select last 13 months )

结果我正在寻找

 November,
 December,
 January,
 February,
 March,
 April,
 May,
 June,
 July,
 August,
 September,
 October,
 November

1 个答案:

答案 0 :(得分:0)

SELECT distinct YEAR(start_date), MONTHNAME(start_date) as month_name 
FROM purchase_order_entry_reports     
WHERE start_date BETWEEN now() - interval 13 month
                     AND now()