Guest User

Untitled

a guest
Nov 15th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. @acum:= @acum + count(mtg.idTemaGestion) as acumulado
  2.  
  3. count(mtg.idTemaGestion)
  4.  
  5. join (SELECT @acum:= 0) r
  6.  
  7. set @acum:= 0;
  8.  
  9. SELECT *, round((c.acumulado / total), 2) as pareto
  10. from (
  11. SELECT tg.detTipoGestion, mtg.detTemaGestion,
  12. (SELECT sum(total) from totalParaCalcular) as total,
  13. count(mtg.idTemaGestion) as totalRegistros,
  14. @acum:= @acum + count(mtg.idTemaGestion) as acumulado
  15. from mac_gestion mg
  16. inner join mac360_mac_gestion mmg on mg.idMacGestion = mmg.idMacGestion_FK
  17. inner join mac360 m on m.idMac360 = mmg.idMac360_FK
  18. inner join mac_tipogestion tg on tg.idTipoGestion = mg.idTipoGestion_FK
  19. inner join datos_nomina dn on dn.idDatosNomina = m.idDatosNominaRecibe_FK
  20. inner join site si on si.idSite = dn.idSite_FK
  21. inner join cuenta_proceso_celula cpc on cpc.idCuentaProcesoCelula =
  22. dn.idCuentaProcesoCelula_FK
  23. inner join cuenta cu on cu.idCuenta = cpc.idCuenta_FK
  24. inner join proceso pro on pro.idProceso = cpc.idProceso_FK
  25. inner join celula ce on ce.idCelula = cpc.idCelula_FK
  26. inner join mac_temagestion mtg on mtg.idTemaGestion = mg.idTemaGestion_FK
  27. join (SELECT @acum:= 0) r
  28. where mg.error = 'si'
  29. and si.idSIte in (2)
  30. and cu.idCuenta in (2)
  31. and pro.idProceso in (25)
  32. and ce.idCelula in (12)
  33. and tg.idTipoGestion in (1)
  34. group by mtg.detTemaGestion
  35. order by count(mtg.idTemaGestion) desc
  36. ) c
  37. WHERE C.ACUMULADO/Total <= 0.80;
Add Comment
Please, Sign In to add comment