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?
| Comment | File | Size | Author |
|---|---|---|---|
| Schermafbeelding 2012-05-30 om 19.14.35.png | 71.78 KB | maxplus |
Comments
Comment #1
merlinofchaos commentedI 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.
Comment #2
maxplus commentedHi 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.
Comment #3
clevername commentedI can't seem to find the open issue either. Unless someone can provide the open issue URL?
Comment #4
clevername commentedSee these posts though:
http://drupal.org/node/1073350
http://drupal.org/node/695298
Comment #5
EmmyS commentedI'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?
Comment #6
Lowell commentedIn 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
Comment #7
Lowell commentedOMG! Totally found conflicting setting, now works as expected...
TURN OFF "Query Settings: Distinct"
Comment #8
tahiticlic commentedNo way to have a GROUP BY displayed in the query... Seems not working with latest version of Views.
Comment #9
cjtriplett commentedDoes not seem to be working for me either. I am also unclear as to why filter and sort criteria have aggregation settings.
Comment #10
Taz commentedAlso 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.
Comment #11
tmsimont commentedthe 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.
Comment #12
arshadsahjavi commentedi 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
Comment #13
tmsimont commented@arsibux -- that has nothing to do with this thread. please open a support request elsewhere.
Comment #14
timwoodI cannot get this to work either.
Comment #15
dawehnerAt least the initial issue seemed to be solved by #1608742-11: Aggregation "Group results together" not generating "Group By" in SQL query
Comment #16
amaisano commentedThis may have been mentioned already, but removing all SORT filters got my GROUP BY query working correctly again.
Comment #17
mgriebe commentedWow. Removing the sort worked for me. That's probably not a feature of SORT.
Comment #18
anthonys commentedIf 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.
Comment #19
damienmckennaPlease test the latest 7.x-3.23 release and let us know if the problem persists, thank you.