0

I'm getting a syntax error, I've changed it multiple times, re-typed it and tried to draw a map even. Now after my head is about to expload, out of desperation I'm turning to someone who has an eye for this.

I might be pushing it trying to grab distinct counts of the iif statements, but probably this question is less technical and more about having an eye...

I don't get problems with the FROM/WHERE clauses but they are provided for additional reference.

Please help me if I'm doing something totally wrong:

(SELECT DISTINCT(COUNT(IIF(ISNULL(CombineTables.[Product Description]),

IIF(ISNULL(CombineTables.[Product Number (OEM)]),


IIF(ISNULL(CombineTables.[Product Number (under supplier PA)],"Incomplete Data",CombineTables.[Product Number (under supplier PA)])),

CombineTables.[Product Number (OEM)]),

CombineTables.[Product Description])))
FROM CombineTables WHERE [PA#]=Forms!PADiagnosticsForm!Combo2 AND "QTR." & " " & CombineTables.Quarter & "-" & CombineTables.Year=Forms!PADiagnosticsForm!List68)

FROM CombineTables
WHERE CombineTables.[Price Agreement Price]*CombineTables.Quantity-CombineTables.[Total Extended Price]<>0 And CombineTables.[PA#]=Forms!PADiagnosticsForm!Combo2 And "QTR." & " " & CombineTables.Quarter & "-" & CombineTables.Year=Forms!PADiagnosticsForm!List68;

I thank you in advance.

4

1 回答 1

1

您的查询有几个问题:

  1. 它是不完整的。第(一个之前的第一个SELECT使它成为第二个之前的表达式FROM CombineTables。因此它缺少一个领先的SELECT. 如果这不是您的完整查询,那么它对试图帮助您的人没有帮助。
  2. NZ(A,B) is identical to and more concise thanIIF(ISNULL(A,B,A))`
  3. 您的 SELECTCOUNT模式是可疑的,尤其是对于所有IIF(ISNULLs。因为实际上,被-ed 的内容永远不会为 NULL,所以您不妨重写asCOUNT中的整个块。 与 SUM 不同的是,它不关心被计算的实际值,它只关心值是否为 NULL(计为 0,任何非 NULL 都计为 1)。COUNTCOUNT(1)COUNT
于 2013-04-02T01:45:56.677 回答