the following query works:
select deb, sum(summa) as Bal from saimnop where deb='23103' group by
deb
union all
select kred, sum(-summa) as Bal from saimnop where kred='23103' group
by kred
giving the result as
DEB BAL
23101 10000
23101 -5000
This is how i see it in MS Excel worksheet (i am doing ODBC via excel
to Interbase using Firebird ODBC driver)
Now i want to sum BAL in order that the result should be 5000 in this
case. Actually this is account balance calculation. Debit and credit
entries are in one table - saimnop.
I tried select sum(Bal) from
(select deb, sum(summa) as Bal from saimnop where deb='23103' group by
deb
union all
select kred, sum(-summa) as Bal from saimnop where kred='23103' group
by kred) group by deb
but it does not work. I have seen similar requests on MS SQL server
groups and my approcah is similar except it does not work.
Thanks for any help
Aivars