Tengo que ejecutar un query de este estilo contra tablas Paradox:
Código:
SELECT COUNT(A.Referencia) Recibos, SUM(B.Cuota) Importe, 1 ForPago, B.PerPago
FROM 'Emision.db' A, 'Persona.db' B
WHERE A.CodPrv = 45 AND A.RefInt LIKE '1%'
AND A.CodPrv = B.CodPrv AND A.Referencia = B.Referencia
AND B.ForPago = 0 AND B.Entidad NOT IN (SELECT Entidad FROM 'Bancos.db')
GROUP BY B.ForPago, B.PerPago
UNION
SELECT COUNT(A.Referencia) Recibos, SUM(B.Cuota) Importe, B.ForPago, B.PerPago
FROM 'Emision.db' A, 'Persona.db' B
WHERE A.CodPrv = 45 AND A.RefInt LIKE '1%'
AND A.CodPrv = B.CodPrv AND A.Referencia = B.Referencia
AND B.ForPago = 1
GROUP BY B.ForPago, B.PerPago
ORDER BY ForPago, PerPago
Se ejecuta a la perfección pero me gustaría que en vez de este resultado:
Cita:
Recibos Importe ForPago PerPago
2 60,00 1 0
1078,0011
60334,0011
343,0012
13141,0012
841.614,00 13
173726.961,00 13
|
se obtuviera este otro:
Cita:
Recibos Importe ForPago PerPago
2 60,00 1 0
70412,00 1 1
16174,00 1 2
182128.575,00 1 3
|
Y no se me ocurre como hacerlo.