我正在使用Views Calc模块但出错

时间:2014-03-04 09:08:36

标签: mysql drupal-7 drupal-views

我在drupal 7中使用Views Calc模块。

我想计算并显示产品价格的总和。

Views Calc模块给出错误 -

SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns
 (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause

请帮助我解决此问题的方法,并告诉我是否有其他替代方法。

1 个答案:

答案 0 :(得分:0)

  

混合GROUP列    (如果没有GROUP BY子句,则没有GROUP列的MIN(),MAX(),COUNT(),...)是非法的。

错误信息非常清楚。您必须使用group by子句在任何列上使用聚合函数。该聚合指令应该通过group by子句传递。

您需要将查询框架化为:

select 
  product_id,
  min(price) min_price,
  max(pric) max_price,
  count(product_id) product_count
from 
  products_table
group by
  product_id