Сальдо спецоснастки ??
Добавлено: 07 июл 2015, 17:54
У когонить есть готовый рецепт получения сальдо МБП на дату ??
Код: Выделить всё
sql select
a1.cGroupMc cGroupMc, a1.kMC kMC, a1.sMC sMC, a1.cMC cMC, a1.cPodr cPodr
,a1.InEkspl InEkspl
, sum(SumOb) SumOb
, sum(Kol)Kol
from
(
select
mbpin.InEkspl InEkspl
, katmc.cGroupMc cGroupMc
, katmc.BarKod kMC
, katmc.name sMC
, katmc.nrec cMC
, mbpin.cpodr cPodr
, MBPIN.SUMMA- MBPIN.SUMMAISNN SumOb
, mbpin.Koldoc Kol
from mbpin inner join katmbp on (mbpin.cmbp = katmbp.nrec) and (mbpin.din <= #date(31,05,2015))
inner join katmc on (katmbp.cmc = katmc.nrec)
union all
select
mbpin.InEkspl InEkspl
,katmc.cGroupMc cGroupMc
, katmc.BarKod kMC
, katmc.name sMC
, katmc.nrec cMC
, mbpin.cpodr cPodr
,-(MBPout.SUMMA- MBPout.SUMMAISNN) SumOb
, -mbpout.Kol Kol
from mbpout inner join mbpin on (mbpout.cMBPIn = mbpin.nrec) and (mbpout.dout <= #date(31,05,2015))
inner join katmbp on (mbpin.cmbp = katmbp.nrec)
inner join katmc on (katmbp.cmc = katmc.nrec)
)a1
group by a1.cGroupMc, a1.kMC, a1.sMC, a1.cMC, a1.cPodr, a1.InEkspl