我的表名错误。有两列月份和qtd。 月列类型为varchar(250)。我希望从此列中获取最近三个月的数据。
My mis table look like.
month qtd
=================
January 12
February 32
March 10
April 34
May 76
June 44
July 12
Output:-
month qtd
May 76
June 44
July 12
答案 0 :(得分:0)
尝试一下:
SELECT *
FROM mis
ORDER BY DATE_FORMAT(STR_TO_DATE(CONCAT(mis.`month`, ' 01 2020'),'%M %d %Y'), "%m") DESC
LIMIT 3