Código SQL:
Ver originalCREATE TABLE #resta(
tipo_mov VARCHAR(200),
monto INT
)
INSERT INTO #resta VALUES ('I',10)
INSERT INTO #resta VALUES ('I',20)
INSERT INTO #resta VALUES ('I',30)
INSERT INTO #resta VALUES ('I',40)
INSERT INTO #resta VALUES ('I',50)
INSERT INTO #resta VALUES ('E',30)
INSERT INTO #resta VALUES ('E',40)
INSERT INTO #resta VALUES ('E',50)
SELECT (SELECT SUM(monto) total FROM #resta WHERE tipo_mov='I') AS ingresos, (SELECT SUM(monto) FROM #resta WHERE tipo_mov='E') AS egresos,
(SELECT SUM(monto)-(SELECT SUM(monto) FROM #resta WHERE tipo_mov='E') total FROM #resta WHERE tipo_mov='I') AS total
saludos!