d7+access 2003 求查询语句
access 2003中目前有两个表:
汇率表:t_exchangeRate
结构:
- SQL code
----ID Fyear Fperiod FNumber FName FExchange-- 1 2011 8 NTD 新台币 0.227-- 2 2011 8 RMB 人民币 1-- 3 2011 8 USD 美元 6.5-- 4 2011 9 NTD 新台币 0.21-- 5 2011 9 RMB 人民币 1-- 6 2011 9 USD 美元 6.47
成本表:t_productCost
结构:
- SQL code
----ID Fyear Fperiod FTotalCostRMB FTotalCostNTD FTotalCostUSD-- 1 2011 8 0.15 ? ?-- 1 2011 9 0.15 ? ?
问题:
知道RMB成本,请问能否用一句语句把FTotalCostNTD(台币成本) FTotalCostUSD(美元成本)更新出来
公式:FTotalCostNTD = FTotalCostRMB *FExchange(新台币),
FTotalCostUSD = FTotalCostRMB *FExchange(美元)
其中汇率是根据年,会计期匹配的
先在这里谢谢各位了,感谢,在这里得到了大家非常多的帮助
[解决办法]
- SQL code
update t_productCost setFTotalCostNTD=FTotalCostRMB*(Select Top 1 FExchange From t_exchangeRate A Where t_productCost.Fyear=A.Fyear And t_productCost.Fperiod=A.Fperiod And A.FNumber='NTD'),FTotalCostUSD=FTotalCostRMB*(Select Top 1 FExchange From t_exchangeRate B Where t_productCost.Fyear=B.Fyear And t_productCost.Fperiod=B.Fperiod And B.FNumber='USD')