Lets say I have a CCK options widget field with 4 options like 1 2 3 4

If I want to get the node count for these values how could I do that?

Also, how would I do it if I would like to put this result in a View and sort on it? Use a computed field?

  • What do you mean by "node count for these values" can you provide us a better example ? – tostinni Jul 31 '11 at 21:28

Views Group By is just what you need. It enriches D6 & Views2 functionality with SQL Grouping and Aggregation capabilities. Once installed, configure it roughly along these lines:

Fields to Group On: Your Field
SQL Aggregation Function: Count
Fields to Aggregate with the SQL Function: Node NID
Fields to Sort Resultset On (after SQL Function is Applied): Your Field
Sort Direction: Descending

Please, note, this will only select those fields that have non-zero number of nodes that they are selected for. To work around that, depending on your scenario you might be able to use a taxonomy vocabulary to replace your options widget and then build a Term View type based on that vocabulary.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.