Skip to content

Instantly share code, notes, and snippets.

Created January 5, 2013 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4462600 to your computer and use it in GitHub Desktop.
Save anonymous/4462600 to your computer and use it in GitHub Desktop.
SELECT gagar.numero_garantia,
gagar.tipo_garantia,
gagop.num_modulo,
gagar.moneda,
SUM(Cast(((((total.saldo_ptamo * 100)/total.total) * gagar.monto) / 100) AS
DECIMAL(
14, 2
))) AS gravamen_instit
FROM gagop
INNER JOIN gagar
ON gagop.num_garantia = gagar.numero_garantia,
(SELECT Sum(prmpr.saldo_ptamo) AS total,
LINEA.linea_credito AS LNA_CREDITO,
LINEA.saldo_ptamo AS SALDO_PTAMO
FROM prmpr,
(SELECT linea_credito,
prmpr.saldo_ptamo
FROM prmpr
WHERE num_ptamo = '00001343435') AS LINEA
WHERE prmpr.linea_credito = LINEA.linea_credito
AND estado <> '7'
AND estado <> '9'
AND estado <> '1'
AND prmpr.saldo_ptamo > 0
GROUP BY prmpr.linea_credito) AS Total
WHERE gagop.num_operacion = TOTAL.lna_credito
GROUP BY gagar.tipo_garantia, gagar.moneda
ORDER BY gagar.tipo_garantia DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment