无法在 drupal 7 视图模块中使用聚合函数
我正在尝试使用视图模块计算价格列表(小数字段)的总和。它只是不想工作......我做错了什么或者......这只是一个错误?
使用软件
- drupal v7.7
- cTools v7.x-1.0-rc1
查看配置 1
- 使用聚合:是 字段
- :标题、sumPricesField
- sumPricesField 的聚合设置:聚合类型 = SUM
- 组列 = 值
结果 1
sumPricesField 在输出中保持空白,唯一的聚合给出值的类型是 COUNT
查看配置 2
- 使用聚合:是
- Fields : Title, sumPricesField
- sumPricesField 的聚合设置 : 聚合类型 = SUM
- 组列 = 值
- 组列(附加)= 实体 ID 结果导致 MySQL 错误
结果 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
I'm trying to calculate the sum of a list of prices (decimal field) with the views module. And it just doesn't want to work... What am I doing wrong or.. is it just a bug ?
Software used
- drupal v7.7
- cTools v7.x-1.0-rc1
View configuration 1
- Use aggregation: Yes
- Fields : Title, sumPricesField
- Aggregation settings of sumPricesField : Aggregation type = SUM
- Group column = Value
Result 1
sumPricesField remains blank in output, the only aggregation type that gives a value is COUNT
View configuration 2
- Use aggregation: Yes
- Fields : Title, sumPricesField
- Aggregation settings of sumPricesField : Aggregation type = SUM
- Group column = Value
- Group columns (additional) = Entity ID result in MySQL error
Result 2
SQL error:
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
Generated Query:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在总结一些浮点字段时遇到了同样的问题。我发现这个补丁为我解决了这个问题 http://drupal.org/node/1194900
补丁后我的网站上也出现了提到的 jQuery 错误,但至少聚合有效。
I had the same problem with SUMming up some float fields. I found this patch which solved the issue for me http://drupal.org/node/1194900
The mentioned jQuery error occurs on my site too after the patch but at least the aggregation works.