gpt4 book ai didi

MYSQL 情况下根本不工作

转载 作者:行者123 更新时间:2023-11-29 11:25:20 25 4
gpt4 key购买 nike

我正在尝试将我的 TIMESTAMP 转换为代表财政年度期间的字符串,例如四月至三月

以下是我的声明:

SELECT Year, Type
CASE
WHEN date_format(SubmissionDate, '%Y')='2015' AND MONTH(SubmissionDate)
BETWEEN 4 AND 12 THEN '15-16'
WHEN date_format(SubmissionDate, '%Y')='2016' AND MONTH(SubmissionDate)
BETWEEN 1 AND 3 THEN '15-16'
END as Year
FROM Incidents

显然它失败了......我很清楚当涉及到 CASE 语句时,我是否接近?

最佳答案

您在类型之后错过了:

SELECT Year, Type,
CASE
WHEN date_format(SubmissionDate, '%Y')='2015' AND MONTH(SubmissionDate)
BETWEEN 4 AND 12 THEN '15-16'
WHEN date_format(SubmissionDate, '%Y')='2016' AND MONTH(SubmissionDate)
BETWEEN 1 AND 3 THEN '15-16'
END as Year
FROM Incidents

关于MYSQL 情况下根本不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38325585/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com