日期:2014-05-17 浏览次数:20646 次
SELECT top 1000000000 tt.员工编号, tt.员工姓名, tt.车间名称, tt.设备编号,tt.设备名称,tt.产品编码,tt.规格型号,tt.图番,tt.工序编码, tt.工序名称,
SUM(tt.A班合格数) AS A班合格数, SUM(tt.A班不良数) AS A班不良数, SUM(tt.A班总数) AS A班总数,
SUM(tt.A班重量) AS A班重量,
SUM(tt.B班合格数) AS B班合格数, SUM(tt.B班不良数) AS B班不良数, SUM(tt.B班总数) AS B班总数,
SUM(tt.B班重量) AS B班重量,
SUM(tt.AB合格数) AS AB合格数, SUM(tt.AB不良数) AS AB不良数, SUM(tt.AB总数) AS AB总数,
SUM(tt.AB班重量) AS AB班重量,
CAST(ROUND(SUM(ISNULL(tt.AB合格数, 0)) / SUM(ISNULL(tt.AB总数, 0)) * 100, 2) AS VARCHAR(100)) + '%' AS AB合格率,
CAST(ROUND(SUM(ISNULL(tt.AB不良数, 0)) / SUM(ISNULL(tt.AB总数, 0)) * 100, 2) AS VARCHAR(100)) + '%' AS AB不良率 ,sum(tt.AB班重量) as 一号,200 as 二号
FROM (
SELECT t1.cPsn_Num AS 员工编号, t1.cPsn_Name AS 员工姓名, t1.cDepName AS 车间名称,t1.SpID as 产品编码,
t1.cinvstd as 规格型号,t1.cinvname as 图番,t1.SCNO as 工序编码,
t1.SCName AS 工序名称, t1.csb_num as 设备编号,t1.csb_name as 设备名称,
ISNULL(t2.A班合格数, 0) AS A班合格数, ISNULL(t3.A班不良数, 0) AS A班不良数,
ISNULL(t2.A班重量, 0) AS A班重量, ISNULL(t1.A班总数, 0) AS A班总数,
ISNULL(t4.B班合格数, 0) AS B班合格数, ISNULL(t5.B班不良数, 0) AS B班不良数,
ISNULL(t4.B班重量, 0) AS B班重量,ISNULL(t1.B班总数, 0) AS B班总数,
ISNULL(t6.AB合格数, 0) AS AB合格数, ISNULL(t7.AB不良数, 0) AS AB不良数,
ISNULL(t6.AB班重量, 0) AS AB班重量,ISNULL(t1.AB总数, 0) AS AB总数
FROM (
SELECT s.cPsn_Num, p.cPsn_Name,
SUM(cast(s.cFieldBody2_HC as int)) AS A班总数,
SUM(cast(s.cFieldBody4_HC as int)) AS B班总数,
SUM(cast(s.cFieldBody5_HC as FLOAT)) AS A班重量,
SUM(cast(s.cFieldBody6_HC as FLOAT)) AS B班重量,
SUM(SpNum) AS AB总数,scp.SCNO, scp.SCName,
d.cDepName, s.SCID,s.cfieldbody2_hc,s.cfieldbody4_hc,s.spicid,s.csb_num,e.csb_name,scp.SpID,f.cinvname,f.cinvstd
FROM HC_SalaryPriceInputCount s
INNER JOIN dbo.WA_psn p ON s.cPsn_Num = p.cPsn_Num
INNER JOIN dbo.HC_SalaryChoseProc scp ON s.SCID = scp.SCID