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?
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.