Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    26

    Unanswered: Understand ms access if statement

    Hi,

    Appreciate some help in interpreting the following ms access if statement. I need to convert it into pl/sql

    IIf(Left([Serial Number],2)="20",Left([Serial Number],7),IIf(Left([serial number],1)="9","19" & Left([serial number],5),""))


    Does it mean

    if the first two characters of serial_number field = 20, then return the first 7 characters,
    if the first character = 9, then return 19 and concatenate it with the first 5 characters of serial number field?

  2. #2
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Heres and SQL statement which does the same.

    SELECT
    CASE
    WHEN LEFT([Serial Number], 2) = '20' THEN LEFT([Serial Number], 7)
    WHEN LEFT([Serial Number], 1) = '9' THEN '19' + LEFT([Serial Number],5)
    ELSE '' END AS strSerialNumber
    FROM dbo.tblDbforum

    The psudologic is:

    If the first 2 characters are "20" return the first 7 characters
    Otherwise if the first character is "9" return "19" concatenated with the first 5 characters.
    Otherwise return a zero length string.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  3. #3
    Join Date
    Nov 2008
    Posts
    26
    Thank you garethdart, great help and explanation

Posting Permissions

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