希望有人能帮助我。
我正在尝试运行此查询,但出现以下错误。我需要根据不同表中的不同字段构建逻辑,然后将该数据写入表中的新字段。这只是我的查询的开始,但我已经收到错误:/
我想写的逻辑是
如果 Containersize = '20' 且 CBMRate PLX < 20MRate then use CBMRatePLX 否则,如果 Containersize = '40' 且 CBMRatePLX < 40MRate then use CBMRatePLX,则使用 20MRate;否则,如果 Containersize = 'LCL' 且,则使用 40MRate CBMRatePLX < LCLMRate the use CBMRatePLX 其他 LCLMRate
这是我编写的查询,但我有一些语法错误。任何帮助,将不胜感激。 :)
Select IIF ([Shipments]![ContainerSize] = '20') ,
(IIF (([CustomerRates]![CBMRate] * [Shipments]![PLX]) < [CustomerRates]![20MRate]) , ([CustomerRates]![CBMRate] * [Shipments]![PLX]) , ([CustomerRates]![20MRate])) , (IIF
([Shipments]![ContainerSize] = '40') ,
(IIF ([CustomerRates]![CBMRate] * [Shipments]![PLX]) < [CustomerRates]![40MRate]), ([CustomerRates]![CBMRate] * [Shipments]![PLX]) , ([CustomerRates]![40MRate])),
(IIF ([CustomerRates]![CBMRate] * [Shipments]![PLX]) < [CustomerRates]![LCLMRate]), ([CustomerRates]![CBMRate] * [Shipments]![PLX]) , ([CustomerRates]![LCLMRate]))
From [CustomerRates] , [Shipments]
Where
[shipments]![customerid]=[customerRates]![customerid]
如果字段是数字类型,请勿使用文本分隔符。
考虑:
IIf([ContainerSize] = 20, IIf([CBMRate] * [PLX] < [20MRate], [CBMRate] * [PLX], [20MRate]),
IIf([ContainerSize] = 40, IIf([CBMRate] * [PLX] < [40MRate], [CBMRate] * [PLX], [40MRate]),
IIf([CBMRate] * [PLX] < [LCLMRate]), [CBMRate] * [PLX], [LCLMRate])))
或者
Switch([ContainerSize] = 20, IIf([CBMRate] * [PLX] < [20MRate], [CBMRate] * [PLX], [20MRate]),
[ContainerSize] = 40, IIf([CBMRate] * [PLX] < [40MRate], [CBMRate] * [PLX], [40MRate]),
True, IIf([CBMRate] * [PLX] < [LCLMRate]), [CBMRate] * [PLX], [LCLMRate]))