Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- cdd.NumeroIdentificacion ,
- cdd.Prestamos ,
- CAST(REPLACE(cdd.Prestamos,',','.') AS FLOAT) * 100 /( SELECT
- SUM(CAST(REPLACE(cdd.Prestamos,',','.') AS FLOAT))
- FROM
- CentralDeDeudores AS a
- WHERE
- a.NumeroIdentificacion = cdd.NumeroIdentificacion
- GROUP BY
- a.NumeroIdentificacion
- ) AS porcentaje
- FROM
- CentralDeDeudores cdd
- GROUP BY
- cdd.NumeroIdentificacion,cdd.Prestamos
- SELECT T1.NumeroIdentificacion ,
- T1.Prestamos/T2.TotalPrestamos
- FROM CentralDeDeudores T1
- INNER JOIN ( SELECT NumeroIdentificacion ,
- SUM(Prestamos) AS 'TotalPrestamos'
- FROM CentralDeDeudores
- GROUP BY
- NumeroIdentificacion
- ) T2
- ON T2.NumeroIdentificacion = T1.NumeroIdentificacion
Add Comment
Please, Sign In to add comment