Friday 13 November 2020

Sqlalchemy max by 2 columns

I need to be able to perform min operation of 2 columns in sqlalchemy. These 2 columns could be from 2 different tables. Pure SQL analog of the operation would be:

Select Id,
       Case When Col1 < Col2 Then Col1
            Else Col2
            End As TheMin
From   TableName

I've been going through the docs and did not find a straightforward way to do that. How this can be implemented in sqlalchemy?



from Sqlalchemy max by 2 columns

No comments:

Post a Comment