Guest User

Untitled

a guest
Apr 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. SELECT
  2. cdd.NumeroIdentificacion ,
  3. cdd.Prestamos ,
  4. CAST(REPLACE(cdd.Prestamos,',','.') AS FLOAT) * 100 /( SELECT
  5. SUM(CAST(REPLACE(cdd.Prestamos,',','.') AS FLOAT))
  6. FROM
  7. CentralDeDeudores AS a
  8. WHERE
  9. a.NumeroIdentificacion = cdd.NumeroIdentificacion
  10. GROUP BY
  11. a.NumeroIdentificacion
  12. ) AS porcentaje
  13.  
  14. FROM
  15. CentralDeDeudores cdd
  16.  
  17.  
  18. GROUP BY
  19. cdd.NumeroIdentificacion,cdd.Prestamos
  20.  
  21. SELECT T1.NumeroIdentificacion ,
  22. T1.Prestamos/T2.TotalPrestamos
  23. FROM CentralDeDeudores T1
  24. INNER JOIN ( SELECT NumeroIdentificacion ,
  25. SUM(Prestamos) AS 'TotalPrestamos'
  26. FROM CentralDeDeudores
  27. GROUP BY
  28. NumeroIdentificacion
  29. ) T2
  30. ON T2.NumeroIdentificacion = T1.NumeroIdentificacion
Add Comment
Please, Sign In to add comment