0

我的代码是这样的,但是第三行中的错误mm/dd/yyyy我的数据库日期格式是这样的:

SELECT
     evep
     year(date='MM/dd/yyyy'),
     month(date='MM/dd/yyyy'),
     Avg(evep)
FROM
     Value
GROUP BY
    evep,
     year(date='MM/dd/yyyy'),
     month(date='MM/dd/yyyy');
4

1 回答 1

0

使用STR_TO_DATE()将您的日期字符串转换为真实日期

SELECT
     evep,
     year(str_to_date(date, '%m/%d/%Y')),
     month(str_to_date(date, '%m/%d/%Y')),
     Avg(evep)
FROM
     Value
GROUP BY
    evep,
     year(str_to_date(date, '%m/%d/%Y')),
     month(str_to_date(date, '%m/%d/%Y'));
于 2013-11-14T13:05:36.387 回答