mysql查询“无效使用组函数”

时间:2016-05-28 06:05:39

标签: mysql database group-by

我有这样的查询

SELECT id_order_history,
       ( MAX(DATE(date_add)) - MIN(DATE(date_add))) AS selisih 
FROM ps_order_history 
WHERE id_order_state IN ('2', '48', '49', '50') 
      AND MONTH (date_add) = '05' 
      AND YEAR (date_add) = '2016' 
      AND (MAX(DATE(date_add)) - MIN(DATE(date_add)) > 5)
GROUP BY id_order

并且

中存在问题
AND (MAX(DATE(date_add)) - MIN(DATE(date_add)) > 5) 

如何解决?

0 个答案:

没有答案