Advertisement
temaon_lieto

SQL declarations

Feb 2nd, 2024
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Started GET "/api/v1/declarations" for ::1 at 2024-02-02 11:07:20 +0200
  2. -- Processing by Api::V1::DeclarationsController#index as HTML
  3.  
  4. SELECT "dbo"."LegalEntities".* FROM "dbo"."LegalEntities" WHERE "dbo"."LegalEntities"."Id" = $1 LIMIT $2  [["Id", 3228], ["LIMIT", 1]]
  5.  
  6. SELECT mv_stat_employees_parties."Id",
  7. mv_stat_employees_parties. "FullName",
  8. mv_stat_employees_parties."PositionRefId",
  9. COUNT(mv_stat_declarations.id) AS total_counter,
  10. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) <= 5) AS age_0_5_counter,
  11. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 6 AND 17) AS age_6_17_counter,
  12. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 18 AND 39) AS age_18_39_counter,
  13. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 40 AND 64) AS age_40_64_counter,
  14. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) >= 65) AS age_65_final_counter FROM "mv_stat_employees_parties" LEFT OUTER JOIN "mv_stat_declarations" ON "mv_stat_declarations"."declaration_status_code" = $1 AND "mv_stat_declarations"."employee_id" = "mv_stat_employees_parties"."Id" WHERE ("mv_stat_employees_parties"."LegalEntityId" = 3228) AND ("mv_stat_employees_parties"."EmployeeTypeRefValue" = 'DOCTOR') AND ("mv_stat_employees_parties"."EmployeeStatusRefValue" = 'APPROVED') GROUP BY "Id", "FullName", "PositionRefId"  [["declaration_status_code", "ACTIVE"]]
  15.  
  16. SELECT "dbo"."PositionRefs".* FROM "dbo"."PositionRefs" WHERE "dbo"."PositionRefs"."Id" = $1  [["Id", 3]]
  17.  
  18. SELECT COUNT(DISTINCT mv_stat_employees_parties."Id") AS total_employee_counter,
  19. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P7' ) AS p7_position_counter,
  20. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P8' ) AS p8_position_counter,
  21. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P9' ) AS p9_position_counter,
  22. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P10' ) AS p10_position_counter,
  23. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P11' ) AS p11_position_counter,
  24. COUNT(DISTINCT mv_stat_declarations.id) AS total_counter,
  25. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) <= 5) AS age_0_5_counter,
  26. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 6 AND 17) AS age_6_17_counter,
  27. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 18 AND 39) AS age_18_39_counter,
  28. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 40 AND 64) AS age_40_64_counter,
  29. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) >= 65) AS age_65_final_counter FROM "mv_stat_employees_parties" LEFT OUTER JOIN "mv_stat_declarations" ON "mv_stat_declarations"."declaration_status_code" = $1 AND "mv_stat_declarations"."employee_id" = "mv_stat_employees_parties"."Id" WHERE ("mv_stat_employees_parties"."LegalEntityId" = 3228) AND ("mv_stat_employees_parties"."EmployeeTypeRefValue" = 'DOCTOR') AND ("mv_stat_employees_parties"."EmployeeStatusRefValue" = 'APPROVED') GROUP BY "LegalEntityId" LIMIT $2  [["declaration_status_code", "ACTIVE"], ["LIMIT", 1]]
  30.  
  31. SELECT mv_stat_employees_parties."Id",
  32. mv_stat_employees_parties. "FullName",
  33. mv_stat_employees_parties."PositionRefId",
  34. COUNT(mv_stat_declarations.id) AS total_counter,
  35. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) <= 5) AS age_0_5_counter,
  36. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 6 AND 17) AS age_6_17_counter,
  37. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 18 AND 39) AS age_18_39_counter,
  38. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 40 AND 64) AS age_40_64_counter,
  39. COUNT(mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) >= 65) AS age_65_final_counter FROM "mv_stat_employees_parties" LEFT OUTER JOIN "mv_stat_declarations" ON "mv_stat_declarations"."declaration_status_code" = $1 AND "mv_stat_declarations"."employee_id" = "mv_stat_employees_parties"."Id" WHERE ("mv_stat_employees_parties"."LegalEntityId" = 3228) AND ("mv_stat_employees_parties"."EmployeeTypeRefValue" = 'DOCTOR') AND ("mv_stat_employees_parties"."EmployeeStatusRefValue" = 'APPROVED') GROUP BY "Id", "FullName", "PositionRefId" LIMIT $2 OFFSET $3  [["declaration_status_code", "ACTIVE"], ["LIMIT", 15], ["OFFSET", 0]]
  40.  
  41. SELECT "dbo"."PositionRefs".* FROM "dbo"."PositionRefs" WHERE "dbo"."PositionRefs"."Id" = $1  [["Id", 3]]
  42.  
  43.  SELECT COUNT(DISTINCT mv_stat_employees_parties."Id") AS total_employee_counter,
  44. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P7' ) AS p7_position_counter,
  45. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P8' ) AS p8_position_counter,
  46. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P9' ) AS p9_position_counter,
  47. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P10' ) AS p10_position_counter,
  48. COUNT(DISTINCT mv_stat_employees_parties."Id") filter ( WHERE mv_stat_employees_parties."PositionRefValue" = 'P11' ) AS p11_position_counter,
  49. COUNT(DISTINCT mv_stat_declarations.id) AS total_counter,
  50. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) <= 5) AS age_0_5_counter,
  51. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 6 AND 17) AS age_6_17_counter,
  52. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 18 AND 39) AS age_18_39_counter,
  53. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) BETWEEN 40 AND 64) AS age_40_64_counter,
  54. COUNT(DISTINCT mv_stat_declarations.id) filter (WHERE extract(year FROM age(cast(mv_stat_declarations."birth_date" AS DATE))) >= 65) AS age_65_final_counter FROM "mv_stat_employees_parties" LEFT OUTER JOIN "mv_stat_declarations" ON "mv_stat_declarations"."declaration_status_code" = $1 AND "mv_stat_declarations"."employee_id" = "mv_stat_employees_parties"."Id" WHERE ("mv_stat_employees_parties"."LegalEntityId" = 3228) AND ("mv_stat_employees_parties"."EmployeeTypeRefValue" = 'DOCTOR') AND ("mv_stat_employees_parties"."EmployeeStatusRefValue" = 'APPROVED') GROUP BY "LegalEntityId"  [["declaration_status_code", "ACTIVE"]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement