我得到这个错误:
select子句出错:“=”附近的表达式。缺少from子句。select子句出错:“,”附近的表达式。无法分析查询文本。
SELECT Sum(subhearingsched.conclusion = 'Conciliated'
AND cases.nature_of_case = 'Criminal') AS criminalconciliated,
Sum(subhearingsched.conclusion = 'Repudiated'
AND cases.nature_of_case = 'Criminal') AS criminalrepudiated,
Sum(subhearingsched.conclusion = 'Arbitrated'
AND cases.nature_of_case = 'Criminal') AS criminalarbitrated,
Sum(subhearingsched.conclusion = 'Certified'
AND cases.nature_of_case = 'Criminal') AS criminalcertified,
Sum(subhearingsched.conclusion = 'Dismissed'
AND cases.nature_of_case = 'Criminal') AS criminaldismissed,
Sum(subhearingsched.conclusion = 'Forwarded'
AND cases.nature_of_case = 'Criminal') AS criminalforwarded,
Sum(subhearingsched.conclusion = 'Mediated'
AND cases.nature_of_case = 'Criminal') AS criminalmediated,
Sum(subhearingsched.conclusion = 'Conciliated'
AND cases.nature_of_case = 'Civil') AS civilconciliated,
Sum(subhearingsched.conclusion = 'Repudiated'
AND cases.nature_of_case = 'Civil') AS civilrepudiated,
Sum(subhearingsched.conclusion = 'Arbitrated'
AND cases.nature_of_case = 'Civil') AS civilarbitrated,
Sum(subhearingsched.conclusion = 'Certified'
AND cases.nature_of_case = 'Civil') AS civilcertified,
Sum(subhearingsched.conclusion = 'Dismissed'
AND cases.nature_of_case = 'Civil') AS civilldismissed,
Sum(subhearingsched.conclusion = 'Forwarded'
AND cases.nature_of_case = 'Civil') AS civilforwarded,
Sum(subhearingsched.conclusion = 'Mediated'
AND cases.nature_of_case = 'Civil') AS civilmediated,
Sum(subhearingsched.conclusion = 'Conciliated'
AND cases.nature_of_case = 'Others') AS othersconciliated,
Sum(subhearingsched.conclusion = 'Repudiated'
AND cases.nature_of_case = 'Others') AS othersrepudiated,
Sum(subhearingsched.conclusion = 'Arbitrated'
AND cases.nature_of_case = 'Others') AS othersarbitrated,
Sum(subhearingsched.conclusion = 'Certified'
AND cases.nature_of_case = 'Others') AS otherscertified,
Sum(subhearingsched.conclusion = 'Dismissed'
AND cases.nature_of_case = 'Others') AS othersdismissed,
Sum(subhearingsched.conclusion = 'Forwarded'
AND cases.nature_of_case = 'Others') AS othersforwarded,
Sum(subhearingsched.conclusion = 'Mediated'
AND cases.nature_of_case = 'Others') AS othersmediated
FROM subhearingsched
JOIN cases
ON ( subhearingsched.caseno = cases.caseno )
这是我的查询,当我在visualstudio query builder中运行它时,它显示了一个解析错误,但在mysql工作台中工作得非常好,而在mysql工作台中工作得非常好但在visualstudio中工作不好的其他查询也出现了这种情况。
1条答案
按热度按时间ny6fqffe1#
不确定您使用的语法是否是mysql方言(因此在mysql workbench中工作),但最好使用标准sql,在“sum”中使用“case”,如下所示: