Hi,
Is it possible to do a calculation on one query result over another?
I have these queries:
select b.purchid, c.purchname, c.orderaccount, sum(a.amountmst), a.dimension
from ledgertrans a
inner join vendpackingslipjour b on a.voucher = b.ledgervoucher
inner join purchtable c on b.purchid = c.purchid
where
a.accountnum = '34050'
and a.dataareaid = 'agl'
and b.dataareaid = 'agl'
and a.voucher like 'GRN-%'
and transdate < '2012-04-01'
and b.purchid = 'PO-000662'
group by b.purchid, c.purchname, c.orderaccount, a.dimension
and
select b.purchid, c.purchname, c.orderaccount, sum(a.amountmst), a.dimension
from ledgertrans a
inner join vendinvoicejour b on a.voucher = b.ledgervoucher
inner join purchtable c on b.purchid = c.purchid
where
a.accountnum = '34050'
and a.dataareaid = 'agl'
and b.dataareaid = 'agl'
and a.voucher like 'PI-%'
and transdate < '2012-04-01'
and b.purchid = 'PO-000662'
group by b.purchid, c.purchname, c.orderaccount, a.dimension
The first query produces:
quote:
purchid purchname orderaccount amount dimension
PO-000662 POD ODO001 -45444.870000000000 BEL
PO-000662 POD ODO001 -81151.510000000000 FMT