Mysql计数与DAYOFWEEK和BETWEEN不一起工作

时间:2014-08-14 22:21:32

标签: mysql between dayofweek

我正在尝试计算一个值,我从工作日和一年的前3个月得到计数。

SELECT 
  SUM(count_LP) AS down1 
FROM
  `splittest` 
WHERE DAYOFWEEK(DATE) = 2 
  AND (
    dato BETWEEN 2014-01-01 
    AND 2014-04-01
  )

当我添加BETWEEN时,它会停止工作。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

指定日期,例如'2014-01-01'

SELECT 
  SUM(count_LP) AS down1 
FROM
  `splittest` 
WHERE DAYOFWEEK(DATE) = 2 
  AND (
    dato BETWEEN '2014-01-01' 
    AND '2014-04-01'
  )