SELECT@rownum row,@rownum :=@rownum + 1 AS num,date_format(DATE_SUB('2017-12-31',INTERVAL @rownum MONTH),'%Y-%m') AS all_dayFROM(SELECT @rownum:=-1) AS r_init,(SELECTc.idFROMt_order cLIMIT 12) AS c_init
https://my.oschina.net/0312/blog/393051