SELECT TOP 100 生产线, 班组, 产品类型, 颜色, 输入日期, CASE WHEN SUM(XS)
<> 0 THEN cast(round((SUM(CASE 数据来源 WHEN '一次合格' THEN XS ELSE 0 END)
+ SUM(CASE 数据来源 WHEN '二次合格' THEN XS ELSE 0 END)) / SUM(XS) * 100, 2)
AS nvarchar(5)) + '%' END AS XS
FROM 输入数据
GROUP BY 生产线, 班组, 产品类型, 颜色, 输入日期
HAVING 输入数据.生产线 = '"&合格率窗体3!生产线&"'
ORDER BY 输入日期 DESC