计数视图中的结果数 [英] Count number of results in a View

查看:114
本文介绍了计数视图中的结果数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算预定义组中有多少人(在SQL中使用SELECT COUNT语句很容易)。我的视图查询运行正常,并显示在我的表中的实际数据,但我只需要知道它找到了多少结果。

I need to count how many people belong in pre-defined groups (this is easy to do in SQL using the SELECT COUNT statement). My Views query runs fine and displays the actual data in my table, but I simply need to know how many results it found.

但是似乎没有COUNT选项在视图中。我猜想我将要使用某种观点挂钩,然后将结果粘贴在表格中。

However there doesn't seem to be a COUNT option in views. I am guessing I am going to have to use some sort of views hook, and then stick the result in the table.

这是一个快速的例子,我正在尝试实现:

Here's a quick example of what i'm trying to achieve:

My Table
----------------------
Group A | 20 people
Group B | 63 people

等等。

(我已经尝试使用Views_Calc模块,但是我收到错误,因为它还不稳定。)

(I've tried using the Views_Calc module, but I get errors because it is not quite stable yet.)

任何人都知道一个简单的方法来计算视图中的结果?

Anybody know of an easy way to count results in Views?

推荐答案

这是一个很好的线程:
http://drupal.org/node/131031

Here's a good d.o thread about it: http://drupal.org/node/131031

虽然如果你只需要计数而不是视图提供的其他内容(字段格式和排序等),为什么不只是编写正确的SELECT COUNT语句并将其称为一天?

Although if you JUST need the count and not the other things Views offers (field formatting & ordering, etc), why not just code up the proper SELECT COUNT statement and call it a day?

(如果你做实际上需要这些视图提供的其他部分,上面有很多例子。)

(If you DO in fact need those other pieces Views offers, there are many examples on that thread above.)

这篇关于计数视图中的结果数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆