[英]hql CASE statement excluding data from query
I have this query in hql: 我在hql中有以下查询:
SELECT d.code as row1, d.name as row2, d.contractor.name as row3,
case when e is null then 'no emission'
else case when e.zone is null then 'no coverage'
else e.zone.name
end
end
FROM Design d
left join d.emissions e
WHERE (d.code =:codeParam or :codeParam = null)
and (d.contractor =:contracParam or :contracParam = null)
I want this to list every Design even if it doesn't have an Emission or the Emission it has doesn't have a zone. 我希望它列出每个设计,即使它没有排放或没有区域也是如此。 If I only do:
如果我只做:
case when e is null then 'no emission'
else 'emission'
end
Every Design is listed correctly, but when I add the second case-when it only lists the Designs with zone. 每个设计都正确列出,但是当我添加第二种情况时(仅列出带区域的设计)。
What am I doing wrong? 我究竟做错了什么? Please tell me if you need more information.
如果您需要更多信息,请告诉我。 Any help will be highly appreciated
任何帮助将不胜感激
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.