[/SRC][src]select NachisID = #DEAL_PROT.NACH_ID
,DealProtocolID = #DEAL_PROT.ID
,DateProtocol = #DEAL_PROT.DATE
,BranchID = op.InstitutionID
,OperationID = op.OperationID
,DealID = dt.DealID
,TaxVid = case
when #DOC_GROUP.BRIEF = @BRIEF_PTAX
then 'Подоходный'
else ''
end
,TaxAmt = case
when #DOC_GROUP.BRIEF = @BRIEF_PTAX
then op.Qty
else $0
end
,AccDebID = op.ResourceID
,AccCreID = op2.ResourceID
,Qty = case
when op.FundID = d.FundID
then op.Qty
else op2.Qty
end
,QtyBs = op.QtyBs
,IsRUR = case
when d.FundID = @RUR then 1
else 0
end
,IsItog = #DOC_GROUP.IS_ITOG
,BriefType = #DOC_GROUP.Brief
from #DEAL_PROT
,tDealTransact dt
,#DOC_GROUP
,tDocMark m41
,tOperPart op
,tDeal d
,tOperPart op2
,tResource r
,tResource r2
where dt.DealProtocolID = #DEAL_PROT.ID
and #DOC_GROUP.ID = dt.AccAnlID
and m41.SPID = @@spid
and m41.Type = 41
and m41.ID = dt.InstitutionID
and op.DealTransactID = dt.DealTransactID
and op.CharType = 1
-- and op.AccountingType&1 = 1
and op.AccountingType = 1
and op.Confirmed <= 1
and op.Confirmed >= @Confirmed
and d.DealID = dt.DealID
and op2.OperationID = op.OperationID
and op2.CharType = (-1) * op.CharType
and op2.AccountingType&1 = 1
and r.ResourceID = op.ResourceID
and r2.ResourceID = op2.ResourceID
В селект надо добавить поле:
a.Value as Basic
с помощью интеграции скрипта:
select a.Value
from tAccrualDetail a
where a.DealProtocolID = 2010018982193
and a.Value <> 0
and a.Date = (select min(a1.Date)
from tAccrualDetail a1
where a1.DealProtocolID = 2010018982193
and a1.Value <> 0)
где 2010018982193 - это одно из значения поля
ID
из таблицы
#DEAL_PROT
p.s.
from #DEAL_PROT
where dt.DealProtocolID = #DEAL_PROT.ID