Consulting

Results 1 to 3 of 3

Thread: access 2007 update query using CASE

  1. #1

    access 2007 update query using CASE

    Hi,

    I tried writing an sql update query for Access 2007 using a case statement. This is the format

    UPDATE titles
           SET price =
                     CASE
                       WHEN (price < 5.0 AND ytd_sales > 999.99)
                                       THEN price * 1.25
                       WHEN (price < 5.0 AND ytd_sales < 1000.00)
                                       THEN price * 1.15
                       WHEN (price > 4.99 AND ytd_sales > 999.99)
                                       THEN price * 1.2
                       ELSE price
            END
    But I found that access does not support such queries. What would be an alternate way to write the query in access to achieve what I want.

    Thanks

  2. #2
    Use iff

    [VBA]
    UPDATE titles
    SET price = IIF (price < 5.0 AND ytd_sales > 999.99, price * 1.25, IIF(price < 5.0 AND ytd_sales < 1000.00, price * 1.15, IIF(price > 4.99 AND ytd_sales > 999.99, price * 1.2, price)))


    [/VBA]

  3. #3
    Ok will try this.
    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •