Advertisement
psi_mmobile

Untitled

Feb 12th, 2021
1,295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 3.35 KB | None | 0 0
  1. -- #1
  2. SELECT v.DAY_OF_WEEK, v.NUMBER_OF_SOT FROM
  3. (
  4.   SELECT gu.gui_user_id,TRUNC(touserdate(sot.work_date,oc.timezone)) AS DAY_OF_WEEK,COUNT(*) AS NUMBER_OF_SOT
  5.   FROM social_office_transaction sot, gu_person gp, person p, gui_users gu, operation_center oc, vo_person_category vopc
  6.   WHERE gu.gui_user_id = gp.gui_user_id
  7.   AND gp.person_id = p.person_id
  8.   AND p.person_id = sot.person_id
  9.   AND gu.operation_center_id = oc.operation_center_id
  10.   AND touserdate(sot.work_date,oc.timezone) BETWEEN TRUNC(SYSDATE,'iw') AND TRUNC(SYSDATE,'iw') + 6
  11.   AND p.person_status_id = 0
  12.   AND p.vo_person_category_id = vopc.vo_person_category_id
  13.   AND NVL(vopc.is_active,'Y') = 'Y'
  14.   GROUP BY gu.gui_user_id,TRUNC(touserdate(sot.work_date,oc.timezone))
  15. ) v
  16. WHERE v.gui_user_id = 101114
  17. ORDER BY 1;
  18.  
  19. -- #2
  20. SELECT v.REPORTED_BY_HOUR, v.NUMBER_OF_BADGES
  21. FROM
  22. (
  23.   SELECT gu.gui_user_id,TO_CHAR(TRUNC(touserdate(vd.gps_full_date,oc.timezone),'HH'),'dd/mm/yyyy HH:MI') AS REPORTED_BY_HOUR, COUNT(vd.vehicle_data_id) AS NUMBER_OF_BADGES
  24.   FROM gui_users gu,operation_center oc, gu_vehicle guv, vehicle v, vo_vehicle_category vovc, vehicle_data vd
  25.   WHERE gu.operation_center_id = oc.operation_center_id
  26.   AND gu.gui_user_id = guv.gui_user_id
  27.   AND guv.vehicle_id = v.vehicle_id
  28.   AND v.vehicle_id = vd.vehicle_id
  29.   AND v.vo_vehicle_category_id = vovc.vo_vehicle_category_id
  30.   AND NVL(vovc.is_active,'Y') = 'Y'
  31.   AND NVL(v.vehicle_status_id,0) = 0
  32.   AND vd.event_type_id = 103
  33.   AND TRUNC(touserdate(vd.gps_full_date,oc.timezone)) = TRUNC(SYSDATE)
  34.   GROUP BY gu.gui_user_id,TRUNC(touserdate(vd.gps_full_date,oc.timezone),'HH')
  35. ) v
  36. WHERE v.gui_user_id = 101114
  37. ORDER BY 1;
  38.  
  39. -- #3
  40. SELECT v.WORK_DATE, v.WORKED_HOURS
  41. FROM (
  42. SELECT gu.gui_user_id, ptd.date_day AS WORK_DATE, SUM(ptd.trf_dhr) AS WORKED_HOURS
  43. FROM gui_users gu, gu_person gp, person p, vo_person_category vopc, pd_trf_day ptd, work_code wc
  44. WHERE gu.gui_user_id = gp.gui_user_id
  45. AND gp.person_id = p.person_id
  46. AND p.person_id = ptd.person_id
  47. AND ptd.work_code_id = wc.work_code_id
  48. AND (wc.work_code_std_type_id = 1 OR wc.work_code_std_category_id = 1)
  49. AND p.vo_person_category_id = vopc.vo_person_category_id
  50. AND p.person_status_id = 0
  51. AND NVL(vopc.is_active,'Y') = 'Y'
  52. AND NVL(wc.is_active,'Y') = 'Y'
  53. AND ptd.date_day BETWEEN TRUNC(SYSDATE,'iw') AND TRUNC(SYSDATE,'iw') + 6
  54. GROUP BY gu.gui_user_id,ptd.date_day
  55. ) v
  56. WHERE gui_user_id = 101042
  57. ORDER BY 1;
  58.  
  59. -- #4
  60. SELECT v.WORK_MONTH,v.WORK_CODE,v.WORKED_HOURS FROM
  61. (
  62.   SELECT gu.gui_user_id, TO_CHAR(TRUNC(ptd.date_day,'mm'),'Month') AS WORK_MONTH,'[' || wc.short_code || ']' || ' ' || wc.work_code_name AS WORK_CODE, SUM(ptd.trf_dhr) AS WORKED_HOURS
  63.   FROM gui_users gu, gu_person gp, person p, vo_person_category vopc, pd_trf_day ptd, work_code wc
  64.   WHERE gu.gui_user_id = gp.gui_user_id
  65.   AND gp.person_id = p.person_id
  66.   AND p.person_id = ptd.person_id
  67.   AND ptd.work_code_id = wc.work_code_id
  68.   AND (wc.work_code_std_type_id = 1 OR wc.work_code_std_category_id = 1)
  69.   AND p.vo_person_category_id = vopc.vo_person_category_id
  70.   AND p.person_status_id = 0
  71.   AND NVL(vopc.is_active,'Y') = 'Y'
  72.   AND NVL(wc.is_active,'Y') = 'Y'
  73.   AND TRUNC(ptd.date_day,'mm') = TRUNC(SYSDATE,'mm')
  74.   GROUP BY gu.gui_user_id,TRUNC(ptd.date_day,'mm'), '[' || wc.short_code || ']' || ' ' || wc.work_code_name
  75. ) v
  76. WHERE v.gui_user_id = 101042
  77. AND worked_hours IS NOT NULL
  78. ORDER BY 3;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement