Guest User

Untitled

a guest
Jul 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. SELECT C.GREGORIAN_MONTH_ID
  2. ,C.BUSINESS_PARTY_ID
  3. ,C.TOTAL_MONTO
  4. ,C.Capitas_Puntuales
  5. ,C.CUIT
  6. ,nb_apellido
  7. ,nb_oficial_actual
  8. ,nb_cne_obe
  9. ,nb_nodo
  10. ,nb_territorio
  11. ,cd_area_negocio
  12.  
  13. FROM (SELECT gregorian_month_id
  14. ,business_party_id
  15. ,Case when BUSINESS_PARTY_ID in (88888,200) then '9999999999999' else business_party_ident_num end CUIT
  16. ,SUM(amt_accum) Total_Monto
  17. ,count(*) Capitas_Puntuales
  18.  
  19. FROM dbsreg.A127932_PARTY_MAIN_PAYROLL_HISTORY
  20. where gregorian_month_id= 201806
  21. group by 1,2,3
  22. ) C
  23.  
  24. LEFT JOIN
  25. (select NU_CUIT, nb_apellido,nb_oficial_actual, nb_cne_obe, nb_nodo, nb_territorio,cd_area_negocio
  26. ,(fh_corte/100 + 190000) gregorian_month_id
  27. from dbsreg.a119527_base_info_gerencial
  28. ) G
  29.  
  30. on C.CUIT = G.NU_CUIT
  31. and (case
  32. when C.gregorian_month_id in (G.gregorian_month_id) then C.gregorian_month_id
  33. else C.gregorian_month_id -1
  34. END) = G.gregorian_month_id
  35. ORDER BY C.BUSINESS_PARTY_ID
Add Comment
Please, Sign In to add comment