2

Ive tried to run the next query

select sum(balance) over (partition by client order by card desc, date_tr desc)
from table_1

And in Result i have the next error message:

FAILED: SemanticException Range based Window Frame can have only 1 Sort key

Is it true, that i cant use 2 sort keys in order by sentence? Or there is a way how can i use 2 sort keys?

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
Denis Plotnikov
  • 105
  • 2
  • 9

2 Answers2

5

Your code should work. The language manual has a very similar example.

That said, an explicit window clause might get around the error:

select sum(balance) over (partition by client
                          order by card desc, date_tr desc
                          rows between unbounded preceding and current row
                         )
from table_1
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
1

Please take a look at this answer to understand the difference between GROUP and PARTITION BY, it should work though it depends what exactly you want: Difference GROUP BY and PARTITION BY

StojimirovicM
  • 36
  • 1
  • 4