I have nodes (articles) in two categories set by two CCK fields (not taxonomy). I want to count the articles of a category. What I did was:

  1. Picked the three fields Node: Title, Content: Category and SQL Aggregation: Group By Fields.
  2. For Fields to Group On:, I picked Content: Category.
  3. For Fields to Aggregate with the SQL function, I picked Node: Title.

The result was that the Node: Title field content has been replaced with a number 1. I believe that is to be processed for counting. Next field shown is the Content: Category.

Problem is, the results were not counted and grouped. It returns all the published articles with the title replaced with the number 1. Is there anything I forgot to set?

View SQL generated:

SELECT node.nid AS nid,
COUNT(node_data_field_1_1.field_1_1_value) AS node_data_field_1_1_field_1_1_value,
node.type AS node_type,
node.vid AS node_vid,
node_data_field_1_1.field_1_3_value AS node_data_field_1_1_field_1_3_value
FROM node node
LEFT JOIN content_type_mp node_data_field_1_1 ON node.vid = node_data_field_1_1.vid
WHERE (node.status <> 0) AND (node.type in ('mp'))
GROUP BY node_data_field_1_1_field_1_3_value, nid, node_type, node_vid
ORDER BY node_data_field_1_1_field_1_1_value ASC

Returned result:

Title: 1
Category: Art
Title: 1
Category: Board usage
Title: 1
Category: Board usage
...

Comments

SanDiego’s picture

I am also having the same problem. It does not group by, instead puts 1 instead of title.

amal850720’s picture

I would suggest you the following. I downgraded to rc1 and everything works well, with a few caveats:

  • The field that you want to be calculated must be listed as the first field.
  • The SQL Aggregation: Group By Field must be listed as the last field.
  • In between above two would be the fields that you want to group.

I tried graphing the output using the latest version of Views Charts (1.0) and everything works fine out of the box.

I'm still trying to figure out what is going on behind the code in rc2 and the workarounds.

timlie’s picture

Which version of views are you using?

I have the same issues as the topic starter. Also with RC1.

amal850720’s picture

The problem only occured to me when I was using rc2, not in rc1. Have you picked the correct fields?

timlie’s picture

Like you described...

amal850720’s picture

Now that's weird. I'll take another look.

loophole080’s picture

same thing with the column of "1"s in the agg field... downgraded to RC1 and works as expected

views 6.x-2.11, core 6.19

(very handy mod BTW thanks!)

peter.bod’s picture

2 works for me too

dasjo’s picture

confirming #2

quiron’s picture

Hi all,

I have the same problem and with the DEV version dated 2011-Feb-25 works fine for me.

jvieille’s picture

Maybe you set a sort criteria : this kills the groupby clause