1. create table ACMS_UNITY_SCORE 
  2.   unity_id      VARCHAR2(40) not null
  3.   product_id    VARCHAR2(40), 
  4.   exam_type     VARCHAR2(40), 
  5.   public_date   DATE
  6.   validate_date DATE
  7.   score         NUMBER(10,2), 
  8.   course_id     VARCHAR2(40), 
  9.   user_id       VARCHAR2(40) not null
  10.   department_id VARCHAR2(40), 
  11.   exam_date     DATE 
  12.  
  13. //------------------------------------ 
  14.  
  15. select count(*) 
  16.   from (select * 
  17.           from (select au.user_id, 
  18.                        au.user_name, 
  19.                        aus.department_id, 
  20.                        max(case aus.course_id 
  21.                              when '1' then 
  22.                               aus.score 
  23.                            endas fg, 
  24.                        max(case aus.course_id 
  25.                              when '2' then 
  26.                               aus.score 
  27.                            endas jc, 
  28.                        max(case aus.course_id 
  29.                              when '3' then 
  30.                               aus.score 
  31.                            endas ds, 
  32.                        max(case aus.course_id 
  33.                              when '4' then 
  34.                               aus.score 
  35.                            endas zs, 
  36.                        au.mobile 
  37.                   from acms_unity_score aus, acms_user au 
  38.                  where to_char(aus.public_date, 'yyyy-MM-dd'between 
  39.                        '2011-02-01' and '2011-12-12' 
  40.                    and (aus.exam_type = 'exam.type.01' or 
  41.                         aus.exam_type = 'exam.type.02'
  42.                    and aus.user_id = au.user_id 
  43.                    and aus.department_id in 
  44.                        (select cd.department_id 
  45.                           from core_department cd 
  46.                          where cd.department_code like '002%'
  47.                  group by au.user_id, 
  48.                           aus.department_id, 
  49.                           au.user_name, 
  50.                           au.mobile) 
  51.          where fg >= 60 
  52.            and jc >= 60 
  53.            and (ds * 0.7 + zs * 0.3) >= 60) 

 

 
  
  1. select * 
  2. from (select au.user_id, 
  3. max(case ar.course_id 
  4. when '1' then 
  5. ar.result 
  6. endas fg, 
  7. max(case ar.course_id 
  8. when '2' then 
  9. ar.result 
  10. endas jc, 
  11. max(case ar.course_id 
  12. when '3' then 
  13. ar.result 
  14. endas ds, 
  15. max(case ar.course_id 
  16. when '4' then 
  17. ar.result 
  18. endas zs 
  19. from acms_result ar, acms_user au 
  20. where ar.user_id = au.user_id 
  21. and ar.batch_id = 'ff80808133343d3d013334b96de72bdc' 
  22. group by au.user_id) 
  23. where fg >= 60 
  24. and jc >= 60 
  25. and (ds * 0.7 + zs * 0.3) >= 60 
  26. ------------------------------------------------------------------------------------- 
  27. select user_name, 
  28. card_id, 
  29. mobile, 
  30. fg, 
  31. jc, 
  32. round(ds * 0.7 + zs * 0.3) 
  33. from (select au.user_id, 
  34. au.user_name, 
  35. au.card_id, 
  36. aus.department_id, 
  37. au.mobile, 
  38. max(case aus.course_id 
  39. when '1' then 
  40. aus.score 
  41. endas fg, 
  42. max(case aus.course_id 
  43. when '2' then 
  44. aus.score 
  45. endas jc, 
  46. max(case aus.course_id 
  47. when '3' then 
  48. aus.score 
  49. endas ds, 
  50. max(case aus.course_id 
  51. when '4' then 
  52. aus.score 
  53. endas zs 
  54. from acms_unity_score aus, acms_user au 
  55. where to_char(aus.exam_date, 'yyyy-MM-dd'between 
  56. '2011-12-01' and '2011-12-22' 
  57. and (aus.exam_type = 'exam.type.01' or 
  58. aus.exam_type = 'exam.type.02'
  59. and aus.user_id = au.user_id 
  60. and aus.department_id in 
  61. (select cd.department_id 
  62. from core_department cd 
  63. where cd.department_code like '%002005034%'
  64. group by au.user_id, 
  65. aus.department_id, 
  66. au.user_name, 
  67. au.card_id, 
  68. au.mobile) 
  69. where fg >= 60 
  70. and jc >= 60 
  71. and (ds * 0.7 + zs * 0.3) >= 60