Home > Software engineering >  Translate a T-SQL query to an Access query
Translate a T-SQL query to an Access query

Time:04-14

I have a T-SQL query that I need to change to an Access query. I tried a lot of times to change it but no success

UPDATE  T1
SET    Cap = ((txg*T2.Cap)/100 ),   
        IPi=(case when t2.TPi=1 then ((txg*T2.IPiTT)/100) else T1.IPi end)
FROM   prg T1
       JOIN main T2
         ON T1.id = T2.id
where T1.Cap=0

CodePudding user response:

Use IIF in Access SQL:

UPDATE
    T1
SET
    Cap = txg * T2.Cap / 100,   
    IPi = IIF(T2.TPi = 1, txg * T2.IPiTT / 100, T1.IPi)
FROM
    prg AS T1
INNER JOIN 
    main AS T2
    ON T1.id = T2.id
WHERE 
    T1.Cap = 0
  • Related