我正在尝试做这样的事情:
x = db_session.query(
Candidate,
func.count(case([(Jobs.interview_type == 'PHONE_SCREEN' and Jobs.interview_type == 'INCLINED' , 1)])),
func.count(case([(Jobs.interview_type == 'PHONE_SCREEN' and Jobs.interview_type == 'NOT_INCLINED', 1)])),
func.count(case([(Jobs.interview_type == 'IN_HOUSE', 1)])),
func.count(case([(Jobs.interview_type == 'EVALUATION', 1)]))
).\
join(Jobs, Jobs.candidate_id == Candidate.candidate_id).\
filter(Candidate.candidate_id == '6236738').\
first()
然而它没有满足第二个条件case
。这可能吗?
我得到它与and_
但它没有给出正确的答案
func.count(case([(and_(Jobs.interview_type == 'PHONE_SCREEN', Jobs.interview_type == 'INCLINED'), 1)])),
应该返回 2,但它返回 0
你需要使用sqlalchemy.and_
而不是and
操作员:
and_(Jobs.interview_type == 'PHONE_SCREEN',
Jobs.interview_type == 'INCLINED')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)