|
各位高人,請指教如下難題!如何將下圖紅色欄位亦通過SQL語句形成計算字段添加至數據透視表中去;表中“結存”是通過
SELECT "本月FCST",* from [FCST$]
union all
SELECT "拉貨中",* from [拉貨$]
union all
SELECT "期初数量",* from [期初$]
union all
SELECT "入库数量",* from [入库$]
union all
SELECT "出库数量",* from [出库$]
union all
select "结存",* from ( select Date,customer,ActualCustomer,PO,Item,期初数量,Cost, AD,Subinventory as 结存数量 from [期初$]
union all
select Date,customer,ActualCustomer,PO,Item,入库数量,Cost, AD,Subinventory from [入库$]
union all
select Date,customer,ActualCustomer, PO, Item,-出库数量,Cost, DN,Subinventory from [出库$])
來實現的,但是在上語句中添加如下紅色字體部分來實現剩餘FCST字段項時
SELECT "本月FCST",* from [FCST$]
union all
SELECT "拉貨中",* from [拉貨$]
union all
SELECT "期初数量",* from [期初$]
union all
SELECT "入库数量",* from [入库$]
union all
SELECT "出库数量",* from [出库$]
union all
select "剩餘FCST",* from (select Date,customer,ActualCustomer,PO,Item,FCST数量,Cost, AD,Subinventory as 剩餘FCST数量 from [FCST$]
union all
select Date,customer,ActualCustomer,PO,Item,-拉貨数量,Cost, AD,Subinventory from [拉貨$]
union all
select Date,customer,ActualCustomer, PO, Item,-入庫数量,Cost, DN,Subinventory from [入库$])
union all
select "结存",* from ( select Date,customer,ActualCustomer,PO,Item,期初数量,Cost, AD,Subinventory as 结存数量 from [期初$]
union all
select Date,customer,ActualCustomer,PO,Item,入库数量,Cost, AD,Subinventory from [入库$]
union all
select Date,customer,ActualCustomer, PO, Item,-出库数量,Cost, DN,Subinventory from [出库$])後,則顯示”查詢無法運行或數據庫表無法打開“請高人幫忙解決,具體如附,感謝!
FCST数量[/td] [td=105] | | | Expr1000 | | | | | | |
Item customer ActualCustomer Subinventory 本月FCST 期初数量 入库数量 出库数量 结存 拉貨中 剩餘FCST
鉛筆 A A Common 6000 500 3500 1000 3000 1000 1500
鉛筆 汇总 6000 500 3500 1000 3000 1000 1500
圓珠筆 B B Common 10000 390 800 300 890 500 8700
圓珠筆 汇总 10000 390 800 300 890 500 8700
|
|