【发布时间】:2012-08-09 12:47:36
【问题描述】:
我所追求的是在 MS Access 中使用 sql 的基础工作量摘要,这就是我想要做的:
Sum(IIf(([Time Report].Destination) Like 'D-[Time Report].[Baselocation]',0)) AS [Total WorkFromBase in P2]
这不起作用,因为 MS Access 不理解正则表达式,我需要附加“D-”才能匹配。
据我所知,我的选择是:
- 学习和使用 VB 宏 (?) 来正确匹配模式
- 使用一组复杂的 IIf 语句,因为 sql 没有原生
else if条件
我不懂VB,只见过example,看不懂。
如果我选择大量 IIf,那么我就有类似的东西
Sum(
IIf(D-[Time Report].[Baselocation] = 'Base1', IIf(
([Time Report].Destination) = 'D-Base1',
IIf(D-[Time Report].[Baselocation] = 'Base2', IIf(
([Time Report].Destination) = 'D-Base2',
IIf(D-[Time Report].[Baselocation] = 'Base3a', IIf(
([Time Report].Destination) = 'D-Base3a' OR ([Time Report].Destination) = 'D-Base3b',
IIf(D-[Time Report].[Baselocation] = 'Base3b', IIf(
([Time Report].Destination) = 'D-Base3a' OR ([Time Report].Destination) = 'D-Base3b', ))
)) AS [Total Work From Base in P1],
然后我得到一个Syntax Error (Missing operator) 类型错误,
那么我怎样才能匹配两个列,并在它们相似时求和?
【问题讨论】: