查询AMResult表NTF数据.sql 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. declare @Line varchar(30)
  2. declare @Station varchar(30)
  3. declare @ODF varchar(30)
  4. declare @TestDate DATE
  5. declare @TestHour INT
  6. declare @THour varchar
  7. set @Line='Test'
  8. set @Station='DataBurning'
  9. set @ODF='DGG7509699'
  10. set @TestDate='2021-12-02'
  11. set @TestHour=10
  12. SELECT * FROM [GET_HOURRESULT] (@Line, @Station, @ODF, @TestDate, @TestHour)
  13. /*
  14. print @Line
  15. select
  16. --抄写总数(包含重流和非重流的)
  17. count(1) as 'Total',
  18. --实际数量:非重流的,即ReDo=0
  19. count(case when ReDo = '0' then 1 else null end) as 'RealTotal',
  20. --有且只有一次测试且成功 Test01=FinalTest=PASS & Test02=NULL
  21. count(case when ResultType = 'OncePass' then 1 else null end) as 'OncePass',
  22. --有且只有一次测试且失败 Test01=FinalTest=FAIL & Test02=NULL
  23. count(case when ResultType = 'OnceFail' then 1 else null end) as 'OnceFail',
  24. --抄写2次或2次以上:Test01=FAIL & Test02=FinalTest=PASS
  25. count(case when ResultType = 'NTF' then 1 else null end) as 'NTF',
  26. --抄写2次或2次以上:Test01=Test02=FinalTest=FAIL
  27. count(case when ResultType = 'TwiceFail' then 1 else null end) as 'TwiceFail',
  28. --2次或2次以上:Test01=PASS & Test02=FinalTest=FAIL
  29. --或者 抄写3次及以上:Test01=Test02=PASS & FinalTest=FAIL
  30. --或者 抄写3次及以上:Test01=FAIL & Test02=PASS & FinalTest=FAIL
  31. count(case when ResultType = 'FinalFail' then 1 else null end) as 'FinalFail',
  32. --2次或2次以上:Test01=Test02=FinalTest=PASS
  33. --或者 抄写3次及以上:Test01=FinalTest=PASS & Test02=FAIL
  34. count(case when ResultType = 'FinalPass' then 1 else null end) as 'FinalPass',
  35. --真实成功:Redo=0的SN.
  36. count(case when FinalTest = 'PASS' and ReDo = '0' then 1 else null end) as 'RealPass',
  37. --真实失败:Redo=0的SN.
  38. count(case when FinalTest = 'FAIL' and ReDo = '0' then 1 else null end) as 'RealFail',
  39. stuff((select ',' + SN from AMResult where Line=@Line and Station=@Station and ODF=@ODF and TestDate=@TestDate and TestHour=@TestHour and ResultType='NTF' for XML PATH('')),1,1,'') as 'NTFSN',
  40. stuff((select ',' + DSN from AMResult where Line=@Line and Station=@Station and ODF=@ODF and TestDate=@TestDate and TestHour=@TestHour and FinalTest='FAIL' for XML PATH('')),1,1,'') as 'FailDSN'
  41. from AMResult where Line=@Line and Station=@Station and ODF=@ODF and TestDate=@TestDate and TestHour=@TestHour
  42. */
  43. select SN,ODF,FinalTest, ResultType, ReDo, Test01, Test02,DSN from AMResult
  44. where Line=@Line and Station=@Station and ODF=@ODF and TestDate=@TestDate and TestHour=@TestHour