
23/12/2017, 15:42
|
| | Fecha de Ingreso: noviembre-2012
Mensajes: 73
Antigüedad: 12 años, 4 meses Puntos: 1 | |
Respuesta: Consulta a 3 tablas Gracias por contestar, entonces se quedaría así:
select t1.id_cuenta, sum(t2.importe) as total form tabla_cuenta as t1
inner join tabla_emitidas as t2 on (t1.idcuenta=t2.idcuenta)
group by t1.id_cuenta
UNION
select suma.*, t3.cobros, suma.total-t3.cobros as gran_total from(
select t1.id_cuenta, sum(t2.importe) as total form tabla_cuenta as t1
inner join tabla_emitidas as t2 on (t1.idcuenta=t2.idcuenta)
group by t1.id_cuenta
) as suma
inner join tabla_cobros as t3 on (suma.idcuenta=t3.idcuenta)
Gracias |