我想在运行时生成Case()。你知道吗
from pypika import Query, Table
table = Table('student')
query = Query.from_(table).select(table.name,
table.age,
table.marks,
Case()
.when(table.marks >= 90, 'A+')
.else('B+').as_('GRADE')
)
print query.get_sql()
即使我能
case = Case()
我无法使用条件将表达式插入其中。你知道吗
基本上,我想知道如何动态地创建when()语句,并在运行时决定运算符和操作数。你知道吗
您可以尝试以下操作:
输出应该是这样的:
相关问题 更多 >
编程相关推荐