I have some of the nodes on my site represent a product and each product has a device type specification via CCK field.
I set up my chart and did the following:

1. Added the Nid field
2. added the device type field
3 set Fields to Group On: field_device_type
4. SQL Function: count
5.Fields to Aggregate with the SQL function: node nid
6.Fields to Aggregate with the SQL function: Nid

All I get is a list that looks like this:

Device Type: Base Station
Products (counted by nid): 1

Device Type: Mobile Station
Products (counted by nid): 1

Device Type: Base Station
Products (counted by nid): 1

Device Type: Base Station
Products (counted by nid): 1

As you can see, stuff is not being grouped together, also if I make it chart style, I get an internal 500 error. I am using the javascript way to make the chart.

This is the query the code is making:

SELECT COUNT(node.nid) AS nid, node_data_field_device_type.field_device_type_value AS node_data_field_device_type_field_device_type_value, node.type AS node_type, node.vid AS node_vid FROM node node LEFT JOIN content_type_cert_prod_db node_data_field_device_type ON node.vid = node_data_field_device_type.vid WHERE node.type in ('cert_prod_db') GROUP BY node_data_field_device_type_field_device_type_value, node_type, node_vid ORDER BY nid ASC

Any help would be awesome!

Becky

Comments

bengibollen’s picture

I have the same problem with dev version. The problem lies in the group statement (I use previous poster´s code as an example):
GROUP BY node_data_field_device_type_field_device_type_value, node_type, node_vid
Only one column to use group by on is selected in configuration, but several (all?) columns are used in the query.

bryancasler’s picture

subscribe

jec006’s picture

Hi Guys,

Please see this node: http://drupal.org/node/385158 for discussion about your issue. We are also looking into ways to make Views Group By work in a more-expected manner.

achton’s picture

Very strange that this exact issue is all over the Views 3 issue queue - see my comment here for a summary.

@jec006: What is the plan for Views Group By and Views 3? Are you the new maintainer, and/or will you work on solving the above directly in Views?

Thanks!
/Achton

jec006’s picture

I am a co maintainer with Irakli - we have added a bit of functionality - we're not sure if Views 3 needs this module as some of the functionality is now built in. I think a user interface that makes it more clear HOW and WHY you are grouping and collating data would resolve this misunderstanding of the way that GROUP BY in SQL is suppose to work.

I think that merlin has commented on this issue quite a bit and is fully aware that the way that GROUP BY appears to work in views and actually works in SQL aren't necessarily always in line. Hopefully we'll get some good ideas/suggestions to make it more understandable and usable for everyone.