Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Posts
    86

    Unanswered: decode equivalent in MS Access

    I have to write a query to display credit card types, however this needs to be done in MS Access. Is there an equivalent function to Oracle's decode in MS Access?

    select name, decode(creditcard,317,'Amex',455,'Visa'), expiry
    from payments

  2. #2
    Join Date
    Jan 2003
    Location
    Rockville, MD
    Posts
    179
    The "switch" function is not the exact equivalent of decode, but can be used similarly.

    Select name, switch(creditcard = 317, "Amex", creditcard = 455, "Visa", True, "(Unspecified)"), expiry
    from payments

  3. #3
    Join Date
    Jan 2004
    Posts
    492

    Re: decode equivalent in MS Access

    Originally posted by kram66
    I have to write a query to display credit card types, however this needs to be done in MS Access. Is there an equivalent function to Oracle's decode in MS Access?

    select name, decode(creditcard,317,'Amex',455,'Visa'), expiry
    from payments

    I believe Iif = Oracle decode - Do a search for IIf and you should get the same functionality

  4. #4
    Join Date
    Feb 2004
    Posts
    86
    IIF dosent seem to be supported by the standard MS Access ODBC driver. Any comments?

  5. #5
    Join Date
    Sep 2003
    Location
    The extremely Royal borough of Kensington, London
    Posts
    778
    select name, "AMEX" As TYPE, expiry
    from table
    where creditcard = 317
    UNION
    select name, "Visa" As TYPE, expiry
    from table
    where creditcard = 455
    Bessie Braddock: Winston, you are drunk!
    Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Posting Permissions

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