本帖最后由 sun 于 2025-1-22 14:33 编辑
SELECT
input1.`二级分类`,
input1.`店仓名称`,
input1.`零售金额`,
input1.`数量`,
input1.`零售价`,
CASE
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 1 THEN '1月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 2 THEN '2月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 3 THEN '3月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 4 THEN '4月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 5 THEN '5月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 6 THEN '6月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 7 THEN '7月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 8 THEN '8月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 9 THEN '9月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 10 THEN '10月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 11 THEN '11月'
WHEN MONTH(input1.`to_date(CAST(单据日期 AS STRING), yyyyMMdd)`) = 12 THEN '12月'
ELSE '未知月份'
END AS 月份
FROM input1;
报错提示语法问题
|