Hi,
I'm using views 7-3.3 and when I activate Aggregation, the "Group Results Together" option doensn't do anything at all. I have turned on "Show the SQL query" in the View-settings and I don't see a "GROUP BY" command in the query.
If I change the aggregation setting to "SUM" or something else, it works and I also see it in the SQL query.

I already tested it with the latest views 7-3.x dev and other versions of views like 7-3.0 and 7-3.1 but with no success.
I also watched all the good screencasts of NodeOne (http://dev.nodeone.se/en/the-aggregation-setting-the-emmajane-episode) where this function actually works.
I'm using Drupal 7.14 but I also tested it on 7.12.

Is this a bug or I'm I doing something wrong?

Comments

merlinofchaos’s picture

Status: Active » Closed (duplicate)

I don't have the nid offhand, but this has been reported. There is some code in the group by that is disabling the group by if there are no aggregated fields, which is wrong. Still not quite sure what that code is doing.

maxplus’s picture

Hi merlinofchaos,

thanks for the quick reply.

I can not find the issue reported before.
If you could send me the nid of the original issue or the temporary solution where to change the code, it would be very helpfull.

clevername’s picture

Status: Closed (duplicate) » Active

I can't seem to find the open issue either. Unless someone can provide the open issue URL?

clevername’s picture

EmmyS’s picture

I'm having the same issue, although not with aggregation per se. I have data relationships that are one-to-many (i.e. one speaker, multiple sessions.) In order to get a view display like this:

Speaker Name: Charles Schultz
Speaker Title: Cartoonist
Speaker Company: United
Sessions:
Drawing Dogs, Thursday at 8 AM
Drawing Children, Friday at 7 PM

I need to group by all the common fields - using the Unformatted List style, I go to Settings and set the group by fields to name, title, and company. If I were writing the SQL query, I would assume there'd be a group_concat somewhere in there, but the preview of the query has no mention of grouping anywhere. And yet the view does work. So where does the grouping happen?

Lowell’s picture

In my case the "Group results together" option does create a GROUP BY in the sql query, however I can't get it to GROUP BY ....value, it seems to be stuck on GROUP BY ...entity_type.

Also there is no indication in the Veiws UI, Fields section where I would expect to see something like

"GROUP RESULTS TOGETHER(Content: my_field) | Aggregation settings"

tested with views 7.x-3.5 and 7.x-3.5+23-dev on drupal 7.17

Lowell’s picture

OMG! Totally found conflicting setting, now works as expected...

TURN OFF "Query Settings: Distinct"

tahiticlic’s picture

No way to have a GROUP BY displayed in the query... Seems not working with latest version of Views.

cjtriplett’s picture

Does not seem to be working for me either. I am also unclear as to why filter and sort criteria have aggregation settings.

Taz’s picture

Also having this issue on the latest views.

It renders fine in the Preview when editing the View, but on render of a content pane, page, block etc, there is the conflict with 'DISTINCT'.

Realising 'Master' had a Distinct, the method in #7 solved this.

tmsimont’s picture

the problem could be that you have more than 1 field set to "Group results together" aggregation type.

If this is the case, then your "GROUP BY" settings will effectively cancel each other out.. You won't have any group-able fields if a combination of groupings spells out unique rows for all results.

For example, I had Commerce Line Item entities, and I wanted to GROUP BY line_item_id.

I was also pulling in a relationship of Commerce Transaction, and showing the Transaction Date.

I didn't want duplicate records for the Transaction. I wanted to GROUP BY line_item_id, but I was still getting duplicate line_item_id's because I had several Commerce Transaction records referring to the same line_item.

The default Aggregation type on the Transaction dates was "Group results together" -- the grouping pulled in additional line_item_id's because grouping on Transaction dates cancelled out grouping on line_item_id's -- there was no GROUP BY in my query.

When I set the Transaction date Aggregation type to "MINIMUM" -- I got my GROUP BY to appear in the results, and only the smallest Commerce Transaction id appeared. This is because instead of indirectly stating that I want unique Transaction Id's (because the Transaction Id's were set to be grouped by default) I said only get me the smallest of Transaction Date's, in the line_item_id group.

I hope that's helpful to someone else.. I thought it was a bug, too, but then I realized it's just a conflict of field settings.

arshadsahjavi’s picture

Component: Miscellaneous » aggregator data
Assigned: Unassigned » arshadsahjavi
Category: bug » task
Priority: Normal » Major

i have Client Content type
having Job content type connected through Client Node reference
having Expense and Income Content type connected with Client and Job Node reference

now
i want view of client wise total expense and total income

tmsimont’s picture

Component: aggregator data » Miscellaneous
Category: task » bug
Priority: Major » Normal

@arsibux -- that has nothing to do with this thread. please open a support request elsewhere.

timwood’s picture

Issue summary: View changes

I cannot get this to work either.

dawehner’s picture

amaisano’s picture

This may have been mentioned already, but removing all SORT filters got my GROUP BY query working correctly again.

mgriebe’s picture

Wow. Removing the sort worked for me. That's probably not a feature of SORT.

anthonys’s picture

If you turn on display of the SQL query you can see if it has additional unexpected GROUP BY entries, for example from the sorting filters. You should only see GROUP BY entries for those you wish to group by. If you have something like group by created date, then you will get no grouping unless the created dates are the same.

damienmckenna’s picture

Version: 7.x-3.3 » 7.x-3.x-dev
Assigned: arshadsahjavi » Unassigned

Please test the latest 7.x-3.23 release and let us know if the problem persists, thank you.