我正在使用Flask-SQLAlchemy,我需要在查询中实现case语句,如下所示:
select j.id, j.record_count, j.ev_job_id, j.created_at, j.csv, t.name,
case
when j.status = 0 then 'Pending'
when j.status = 1 then 'Complete'
end status
from job_status j
inner join list_types t on (j.list_type_id = t.id)
order by j.id desc
答案 0 :(得分:2)
SQLAlchemy文档在此解释了它们的case语句实现:
或者您可能会发现其他SO问题有用: