Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. SELECT
  2. Sum(l.cslbr_temp + l.cslbr_wkr) AS TTL,
  3. Sum(l.cslbr_temp) AS Temp,
  4. Sum(l.cslbr_wkr) AS Worker,
  5. l.subprocess_id
  6. FROM
  7. vw_cslabor l,
  8. vm_subprocess s
  9. WHERE
  10. s.SUBPROCESS_ID(+) = l.SUBPROCESS_ID
  11. AND l.cslbr_type not in ('FC','DC','PR','IS')
  12. AND l.CSLBR_TYPE not in
  13. (
  14. Case
  15. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = '0' /*ALLO_TYPE_PRIMARY*/ Then '---N/A---'
  16. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = 'F' /*ALLO_TYPE_FACTORYCOM*/ Then 'FC' --LABOR_FACTORYCOM
  17. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = 'D' /*ALLO_TYPE_DEPTCOM*/ Then 'FC,DC' --LABOR_FACTORYCOM || ',' || LABOR_DEPTCOM
  18. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = 'P' /*ALLO_TYPE_PROCESS*/ Then 'FC,DC,PR' --LABOR_FACTORYCOM || ',' || LABOR_DEPTCOM || ',' || LABOR_PROCESS
  19. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = 'I' /*ALLO_TYPE_INDIRECT*/ Then 'FC,DC,PR,IS' --LABOR_FACTORYCOM || ',' || LABOR_DEPTCOM || ',' || LABOR_PROCESS || ',' || LABOR_INDIRECTSUB
  20. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = 'C' /*ALLO_TYPE_SUBPROCOM*/ Then 'FC,DC,PR,IS,SC' --LABOR_FACTORYCOM || ',' || LABOR_DEPTCOM || ',' || LABOR_PROCESS || ',' || LABOR_INDIRECTSUB || ',' || LABOR_DIRECTSUBCOM
  21. When /*lrec_AllocationTypeLoop.Allocationtype*/ 'I' = 'S' /*ALLO_TYPE_SUBPRO*/ Then 'F,D,P,I,C,S'--LABOR_FACTORYCOM || ',' || LABOR_DEPTCOM || ',' || LABOR_PROCESS || ',' || LABOR_INDIRECTSUB || ',' || LABOR_DIRECTSUBCOM || ',' || LABOR_DIRECTSUB
  22. Else '---N/A---'
  23. End
  24.  
  25. )
  26. GROUP BY l.SUBPROCESS_ID
  27.  
  28. WITH allocation_type_combinations AS (
  29. SELECT 'F' AS allocation_descriptor, 'FC' AS allocation_method FROM dual
  30. UNION
  31. SELECT 'D' AS allocation_descriptor, 'FC' AS allocation_method FROM dual
  32. UNION
  33. SELECT 'D' AS allocation_descriptor, 'DC' AS allocation_method FROM dual
  34. UNION
  35. SELECT 'P' AS allocation_descriptor, 'FC' AS allocation_method FROM dual
  36. UNION
  37. SELECT 'P' AS allocation_descriptor, 'DC' AS allocation_method FROM dual
  38. UNION
  39. SELECT 'P' AS allocation_descriptor, 'PR' AS allocation_method FROM dual
  40. UNION
  41. SELECT 'I' AS allocation_descriptor, 'FC' AS allocation_method FROM dual
  42. UNION
  43. SELECT 'I' AS allocation_descriptor, 'DC' AS allocation_method FROM dual
  44. UNION
  45. SELECT 'I' AS allocation_descriptor, 'PR' AS allocation_method FROM dual
  46. UNION
  47. SELECT 'I' AS allocation_descriptor, 'IS' AS allocation_method FROM dual
  48. UNION
  49. SELECT 'C' AS allocation_descriptor, 'FC' AS allocation_method FROM dual
  50. UNION
  51. SELECT 'C' AS allocation_descriptor, 'DC' AS allocation_method FROM dual
  52. UNION
  53. SELECT 'C' AS allocation_descriptor, 'PR' AS allocation_method FROM dual
  54. UNION
  55. SELECT 'C' AS allocation_descriptor, 'IS' AS allocation_method FROM dual
  56. UNION
  57. SELECT 'C' AS allocation_descriptor, 'SC' AS allocation_method FROM dual
  58. UNION
  59. SELECT 'S' AS allocation_descriptor, 'F' AS allocation_method FROM dual
  60. UNION
  61. SELECT 'S' AS allocation_descriptor, 'D' AS allocation_method FROM dual
  62. UNION
  63. SELECT 'S' AS allocation_descriptor, 'P' AS allocation_method FROM dual
  64. UNION
  65. SELECT 'S' AS allocation_descriptor, 'I' AS allocation_method FROM dual
  66. UNION
  67. SELECT 'S' AS allocation_descriptor, 'C' AS allocation_method FROM dual
  68. UNION
  69. SELECT 'S' AS allocation_descriptor, 'S' AS allocation_method FROM dual
  70. )
  71. SELECT
  72. Sum(l.cslbr_temp + l.cslbr_wkr) AS TTL,
  73. Sum(l.cslbr_temp) AS Temp,
  74. Sum(l.cslbr_wkr) AS Worker,
  75. l.subprocess_id
  76. FROM
  77. vw_cslabor l,
  78. vm_subprocess s
  79. WHERE
  80. s.SUBPROCESS_ID(+) = l.SUBPROCESS_ID
  81. AND l.cslbr_type not in ('FC','DC','PR','IS')
  82. AND l.CSLBR_TYPE not in
  83. (SELECT allocation_method FROM allocation_type_combinations WHERE allocation_descriptor = 'F')
  84. GROUP BY l.SUBPROCESS_ID
  85.  
  86. WITH allocation_type_combinations AS (
  87. SELECT 'F' AS allocation_descriptor, 'FC' AS allocation_type_group FROM dual
  88. UNION
  89. SELECT 'D' AS allocation_descriptor, 'FC,DC' AS allocation_type_group FROM dual
  90. UNION
  91. SELECT 'P' AS allocation_descriptor, 'FC,DC,PR' AS allocation_type_group FROM dual
  92. UNION
  93. SELECT 'I' AS allocation_descriptor, 'FC,DC,PR,IS' AS allocation_type_group FROM dual
  94. UNION
  95. SELECT 'C' AS allocation_descriptor, 'FC,DC,PR,IS,SC' AS allocation_type_group FROM dual
  96. UNION
  97. SELECT 'S' AS allocation_descriptor, 'F,D,P,I,C,S' AS allocation_type_group FROM dual
  98. ),
  99. allocation_discriptors AS (
  100. SELECT DISTINCT
  101. allocation_descriptor,
  102. TRIM(REGEXP_SUBSTR(allocation_type_group, '[^,]+', 1, level)) AS allocation_method
  103. FROM
  104. allocation_type_combinations
  105. CONNECT BY INSTR(allocation_type_group, ',', 1, level - 1) > 0
  106. )
  107. SELECT
  108. Sum(l.cslbr_temp + l.cslbr_wkr) AS TTL,
  109. Sum(l.cslbr_temp) AS Temp,
  110. Sum(l.cslbr_wkr) AS Worker,
  111. l.subprocess_id
  112. FROM
  113. vw_cslabor l,
  114. vm_subprocess s
  115. WHERE
  116. s.SUBPROCESS_ID(+) = l.SUBPROCESS_ID
  117. AND l.cslbr_type not in ('FC','DC','PR','IS')
  118. AND l.CSLBR_TYPE not in
  119. (SELECT allocation_method FROM allocation_discriptors WHERE allocation_descriptor = 'I')
  120. GROUP BY l.SUBPROCESS_ID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement