关闭

在Drupal在统计记录的数量

468人阅读 评论(0) 收藏 举报
分类:

原文在这里

http://drupal.stackexchange.com/questions/20705/count-results-in-views-using-aggregation


Yes, it is possible in Views 3 out of the box.
The idea is the same as in SQL aggregations. Lets see an example:

  1. Edit your view and enable Views aggregations:
    enable Views aggregations

  2. Remove default sort criteria.

  3. Add fields “Content: Type” and “Content: Nid”: enter image description here
    Select COUNT function for Content: Nid: enter image description here

To see what happens just turn on checkbox “Show the SQL query” at global Views settings page.

SELECT node.type AS node_type, COUNT(node.nid) AS nid
FROM 
{node} node
WHERE (( (node.status = '1') ))
GROUP BY node_type
LIMIT 10 OFFSET 0

So, we are grouping nodes by node_type and calculating count for this groups.


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:291279次
    • 积分:4040
    • 等级:
    • 排名:第7980名
    • 原创:96篇
    • 转载:94篇
    • 译文:22篇
    • 评论:51条
    最新评论