不能在drupal 7视图模块中使用聚合函数

时间:2011-08-07 14:47:26

标签: mysql drupal drupal-views

我正在尝试使用views模块计算价格列表(十进制字段)的总和。它只是不想工作......我做错了什么或者......它只是一个错误?

使用的软件

  • drupal v7.7
  • cTools v7.x-1.0-rc1

查看配置1

  • 使用聚合:是
  • 字段:标题,sumPricesField
  • sumPricesField的聚合设置:聚合类型= SUM
  • 组列=值

结果1

sumPricesField在输出中保持空白,唯一给出值的聚合类型是COUNT

查看配置2

  • 使用聚合:是
  • 字段:标题,sumPricesField
  • sumPricesField的聚合设置:聚合类型= SUM
  • 组列=值
  • 组列(附加)= MySQL错误中的实体ID结果

结果2

SQL错误:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in 
your SQL syntax; check the manual that corresponds to your MySQL server version 
for the right syntax to use near 'id) AS field_data_field_algembeo_entityid FROM
drupal_node node LEFT JOIN drupa' at line 1

生成的查询

SELECT 
  node.title AS node_title, 
  node.nid AS nid, 
  node.created AS node_created, 
  MIN(node.nid) AS nid_1, 
  'node' AS field_data_field_bedrag_node_entity_type,
  SUM(field_data_field_bedrag.field_bedrag_value) AS field_data_field_bedrag_field_bedrag_value, 
  SUM(field_data_field_bedrag.entity id) AS field_data_field_bedrag_entityid
FROM 
  {node} node
  LEFT JOIN {field_data_field_bedrag} field_data_field_bedrag ON node.nid = field_data_field_bedrag.entity_id AND (field_data_field_bedrag.entity_type = node AND field_data_field_bedrag.deleted = 0)
WHERE 
  (( (node.status = '1') ))
GROUP BY 
  node_title, nid, node_created
ORDER BY 
  node_created DESC
LIMIT 
  10 OFFSET 0

1 个答案:

答案 0 :(得分:0)

我在使用一些浮点字段时遇到了同样的问题。我发现这个补丁解决了我的问题http://drupal.org/node/1194900 在补丁之后,我的网站上也会出现上面提到的jQuery错误,但至少聚合有效。