1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How Do I have Multiple Sorts in a Window Function in SQLAlchemy?

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024.

  1. Stack

    Stack Membro Participativo

    I have a SQLAlchemy query with a row_number function like this which works fine:

    func.row_number().over(order_by=a.desc())


    What I'd like to do is add a second sort to help with "tie breaking". I've tried:

    func.row_number().over(order_by=a.desc(),b.desc())


    Which I didn't really expect to work. I've also tried:

    func.row_number().over(order_by=(a.desc(),b.desc()))


    and

    func.row_number().over(order_by=[a.desc(),b.desc()])


    Those didn't work either.

    I haven't found a syntax example online, hence my question - How do you do multiple sorts in a window function using sqlalchemy?

    Continue reading...

Compartilhe esta Página