我的登台表中有Month_year列,其中包含以下数据。请建议查询以获取所需的输出。
输入:
+----------+
month_year
+----------+
Jan-19
Dec-18
+----------+
预期输出:
+----------+
month_year
+----------+
201901
201812
+----------+
预先感谢!
答案 0 :(得分:0)
If column's month_year date format is MMM-yy then contact 01 as default date for avoid to null result, however it will not effect expected out because you are going to get output in format yyyyMM.
Try this:
select from_unixtime(unix_timestamp(concat('01-',month_year),'dd-MMM-yy'),'yyyyMM')