在增加一个条件审核结果
时间: 2024-03-24 16:35:44 浏览: 52
可以在原有的 SQL 语句中增加一个条件,例如:
```
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, " +
"COUNT(*) AS TotalCount, " +
"ROUND(SUM(CASE WHEN 季度 = 'Q1' THEN 1 ELSE 0 END)/COUNT(*)*100,2)||'%' AS Q1Percent, " +
"ROUND(SUM(CASE WHEN 季度 = 'Q2' THEN 1 ELSE 0 END)/COUNT(*)*100,2)||'%' AS Q2Percent, " +
"ROUND(SUM(CASE WHEN 季度 = 'Q3' THEN 1 ELSE 0 END)/COUNT(*)*100,2)||'%' AS Q3Percent, " +
"ROUND(SUM(CASE WHEN 季度 = 'Q4' THEN 1 ELSE 0 END)/COUNT(*)*100,2)||'%' AS Q4Percent " +
"FROM FAIsum " +
"WHERE 审核年份 = '2021' AND 审核结果 = '通过' " + // 增加审核结果的条件
"GROUP BY 季度";
```
其中,我在原有的 SQL 语句中增加了一个 `WHERE` 条件,来筛选审核年份为 2021 且审核结果为通过的数据。你可以根据实际情况修改这个条件。
阅读全文