语法错误 string query1 = "SELECT 季度,COUNT(CASE WHEN 季度 = 'Q1' THEN 1 ELSE NULL END) AS Q1Count, COUNT(CASE WHEN 季度 = 'Q2' THEN 1 ELSE NULL END) AS Q2Count,COUNT(CASE WHEN 季度 = 'Q3' THEN 1 ELSE NULL END) AS Q3Count,COUNT(CASE WHEN 季度 = 'Q4' THEN 1 ELSE NULL END) AS Q4Count ,审核年份 FROM FAIsum 审核年份 = @value1 GROUP BY 季度,审核年份";
时间: 2024-04-01 13:35:31 浏览: 79
condition:函数式条件判断语法,用于替代if else、case when语法
5星 · 资源好评率100%
这段代码中仍然存在语法错误,缺少了一个 WHERE 关键字,应该将"FROM FAIsum 审核年份"修改为"FROM FAIsum WHERE 审核年份",即:
string query1 = "SELECT 季度,COUNT(CASE WHEN 季度 = 'Q1' THEN 1 ELSE NULL END) AS Q1Count, COUNT(CASE WHEN 季度 = 'Q2' THEN 1 ELSE NULL END) AS Q2Count,COUNT(CASE WHEN 季度 = 'Q3' THEN 1 ELSE NULL END) AS Q3Count,COUNT(CASE WHEN 季度 = 'Q4' THEN 1 ELSE NULL END) AS Q4Count ,审核年份 FROM FAIsum WHERE 审核年份 = @value1 GROUP BY 季度,审核年份";
阅读全文