-1

I am trying to make a query on Google Sheets and sort the results according to the highest values on column C. The range I am doing the query on is $A$6:$O.

I have tried to do it like this:

=SORT(QUERY(($A$6:$O), "Select A, B, C, D,E,F,G,H,I group by C"))

However, I am always getting an error saying

#VALUE: Unable to parse query string for Function QUERY parameter 2: CANNOT_GROUP_WITHOUT_AGG

Do you have any idea about how I can make this work?

ekad
  • 14,436
  • 26
  • 44
  • 46
franciscofcosta
  • 833
  • 5
  • 25
  • 53
  • 1
    Grouping is not the behavior you want. Grouping means to show only the unique rows of the grouped column with the other columns, and all non-grouped columns are required to be singularly valued (i.e. aggregated e.g. `SUM(A)`). You should review the query language reference. – tehhowch Mar 12 '18 at 11:53

1 Answers1

1

Use the ORDER BY clause in place of GROUP BY.

ttarchala
  • 4,277
  • 2
  • 26
  • 36
  • Thank you for your help. I have tried to use order by and the error doesn't occur. However, I can't change the order in which the results are presnted. I would like for the results to appear in a descending order and, as such, have written "order by C desc" but it doesn't seem to work. – franciscofcosta Mar 12 '18 at 13:09
  • 3
    @franciscofcosta if you are imposing an external sort on the result of query, then **of course** the `ORDER BY` clause has no effect. – tehhowch Mar 12 '18 at 13:11