如何使用SQL Alchemy ORM的别名隐藏给定的SQL Case表达式
SELECT `id` AS `emailId`, `email`, `type`,
CASE WHEN `type` = 'Home' THEN 1
WHEN `type` = 'Work' THEN 2
ELSE 4 END `s_order`
FROM `emails`
WHERE `id` = '1121212'
ORDER BY `s_order` ASC'
我知道情况可以这样使用
from sqlalchemy import case
stmt = select([users_table]).\
where(
case(
[
(users_table.c.name == 'wendy', 'W'),
(users_table.c.name == 'jack', 'J')
],
else_='E'
)
)
但是我如何包含s_order
?