直接上代码:
SELECT dealDate,strftime('%Y-%m',dealDate) as yearMonth
FROM main.test4
GROUP BY yearMonth
ORDER BY yearMonth ASC;
结果如下
dealDate是原始时间列,yearMonth是格式化之后的列
dealDate yearMonth
2010-12-15 2010-12
2012-02-26 2012-02
2012-03-30 2012-03
2012-04-29 2012-04
2012-05-31 2012-05
2012-06-30 2012-06
2012-07-31 2012-07
2012-08-28 2012-08
2012-09-18 2012-09
2012-10-29 2012-10
2012-11-25 2012-11
2012-12-30 2012-12
2013-01-27 2013-01
2013-02-26 2013-02
2013-03-31 2013-03
2013-04-30 2013-04
2013-05-26 2013-05
2013-06-13 2013-<