Question

I need to run a T-SQL query via the Microsoft Query interface, using an IIf statement.

When I run the query, I get the error Missing FROM clause. This is odd, because the FROM clause is there. It fails because of the IIf but I have no idea why.

The code:

SELECT 
    TABLE1.NUMBER, 
    TABLE1.TEXT, 
    TABLE1.INT, 
    IIf(
        (
            (
                ((TABLE2.INT1-TABLE2.INT2) -TABLE2.INT3) -TABLE2.INT4
            ) > 0
        ), 
        (
            1
        ),  0) 
        as NEWCOL
FROM 
    DB.TABLEX TABLE1, 
    DB.TABLEY TABLE2
WHERE 
    TABLE2.NUMBER = TABLE1.NUMBER 
    AND TABLE1.NUMBER='991208000192'

The database is not mine, so I have to work with what I can. Does anyone have an idea what may cause the problem?

Was it helpful?

Solution

the SQLBase reference in http://enos.itcollege.ee/~priit/(I216)%20Ab-de%20administreerimine/SQLBase%20admin%20juhendid/LANG.PDF (Courtesy @twoleggedhorse) does not have function IIF in SQLBase. It has a function IF with similar syntax as your IIF.

Try using @IF(CONDITION, TRUE_VAL, FALSE_VAL) in your SQL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top