我有以下表格输出 - 我有什么:
Account No Description Seg1 Seg2 Seg3 Budget PeriodBalance
000-1120-00 Cash 000 1120 00 $1,000.00 $2,000.00
000-1130-00 Asset 000 1130 00 $1,500.00 $3,000.00
我想拥有什么:
Account No Description Seg1 Seg2 Seg3 Budget PeriodBalance
000-1120-01 Cash 000 1120 01 $700.00 $1,300.00
000-1120-02 Cash 000 1120 02 $900.00 $1,700.00
000-1130-00 Asset 000 1130 00 $1,500.00 $3,000.00
在这里,如果Seg2等于1120,那么我想将其拆分为2个帐户,后面是帐号No 01和02代替00中的段3.一旦我有了,我想获得预算以及新账户的期限。我的原始查询如下(Dynamics GP数据库Fabrikam):
Select
rtrim(c.Actnumbr_1) +'-'+ rtrim(c.Actnumbr_2)+ '-'+ rtrim(c.Actnumbr_3) as ACTNUMST,
c.ACTINDX,
c.ACTDESCR,
c.ACTNUMBR_1,
c.ACTNUMBR_2,
c.ACTNUMBR_3,
sum(a.PERDBLNC) as Period_Balance,
b.BUDGETAMT,
a.year1,
'' as docdate,
''as Vendname,'' as PONUMBER,
0 as PO_Amount,
0 as 'Not_Received_Amount',
0 as ENCMBAMT
from GL00100 c
left outer join GL11110 a on c.ACTINDX = a.ACTINDX
Left outer join
(Select
actindx,
sum(budgetamt) as budgetamt
from GL00201
where BUDGETID = 'budget2017'
and periodid <= 12 group by actindx) b
on c.ACTINDX = b.ACTINDX
where
a.PERIODID <= 12 and
a.year1 = '2017' and a.actindx < '18'
group by
c.ACTDESCR, c.ACTNUMBR_1, c.ACTNUMBR_2, c.ACTNUMBR_3, a.year1,c.ACTINDX,b.BUDGETAMT
任何帮助都将受到高度赞赏。