SELECT Товары.[Код товара], Товары.[Наименование товара], Товары.[Цены за ед товара], (Товары.[Цены за ед товара]*Заказы.[Количество, шт]*0.9) AS [Стоимость заказа со скидкой], (Товары.[Цены за ед товара]*Заказы.[Количество, шт]) AS [Стоимость заказа], IIF ([Стоимость заказа]>[Средняя цена].[Средняя цена], [Стоимость заказа]*1) AS [Скидка] INTO [Таблица 5] FROM [Средняя цена], Заказы INNER JOIN Товары ON Заказы.[Код товара] = Товары.[Код товара]; 

Gives an error message

Syntax error (operator omitted) in the query expression "IIF ([Order value]> [Average price]. [Average price], [Order cost] * 1) AS [Discount]".

What could be the error? According to my feelings, everything is according to the documentation, but what's wrong? Thank

  • one
    if everything is in accordance with the documentation, then where the third parameter is IIF ( expr , truepart , falsepart ) - teran
  • thank. and when falsepart is present, it duplicates records and ignores truepart - it always dumps into falsepart. what could be the reasons? DISTINCT does not work. thanks - J. Doe

1 answer 1

You cannot refer to the [Order value] alias here. You can use subqueries, i.e. the alias is specified in the inner query and is used in the outer one.

As for the third parameter in IIF, the default is NULL.

  • How do you debug ms access? Faced with the fact that it is very difficult to establish a link between the access-a reaction and reality. (speech about 2007 version) - J. Doe