
Calculo de ingresos menos egresos de varias tablas
Publicado por Jasson (2 intervenciones) el 14/01/2022 22:28:25
De ante mano muchas gracias, necesito el total de Ingresos de esas tablas (Un unico resultado) restado en un solo resultado con el total de egresos de esas dos tablas
en sql 2014 forzadamente :(
en sql 2014 forzadamente :(
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
------------------------------------Ingresos--------------------------------------------------------------
SELECT Fecha, SUM(MontoPrincipal) as total FROM Recibos
WHERE (Fecha = convert (date,getdate()))
GROUP by Fecha
union
SELECT Fecha, SUM(MontoFactura) FROM Pagos
WHERE (Fecha = convert (date,getdate()))
GROUP by Fecha
union
SELECT Fecha, sum(MontoDebe - MontoHaber)FROM IngresosEgresos
WHERE (Fecha = convert (date,getdate()))
group by Fecha
union
SELECT Fecha, sum(MontoAbonado)
FROM ApartadosAbonos
WHERE (Fecha = convert (date,getdate()))
group by Fecha
---------------------------------------Egresos----------------------------------------------------
SELECT Fecha, SUM (MontoHaber) AS TOTAL_EGRESOS FROM IngresosEgresos
where Fecha = CONVERT (date, getdate())
GROUP BY Fecha
union
SELECT Fecha, SUM (Subtotal+Igv-Descuento) AS TOTAL_EGRESOS FROM Compras
where Fecha = CONVERT (date, getdate())
GROUP BY Fecha
Valora esta pregunta


0