-1

I need to review this query:

=QUERY('BD3'!A:Q, "SELECT D,Q, SUM(M) WHERE I='W34' AND M>0 AND L='Huacho' GROUP BY D,Q ORDER BY SUM(M) DESC LIMIT 5",-1)

I obtain this:
Obtained this

But I need something like this:
How it should be

ZygD
  • 22,092
  • 39
  • 79
  • 102
  • 1
    Welcome to SO! Please read [how to ask](https://stackoverflow.com/help/how-to-ask) (specifically `Help others reproduce the problem`) and edit your question to include the example as text, not as an image - `DO NOT post images of code, data, error messages, etc.`. Please include some example data as well. – WOUNDEDStevenJones Aug 26 '21 at 17:30
  • share a copy of your sheet – player0 Aug 26 '21 at 19:22

1 Answers1

0

For the result you want, the correct SQL function should be:

RANK() OVER (PARTITION BY D, Q ORDER BY SUM(M) DESC

You can check this answer for detail explanations: Array Formula to Rank Column A Partition by Column B And C

ccommjin
  • 87
  • 5