Results 1 to 5 of 5

Thread: using views

  1. #1
    Join Date
    Feb 2003
    Posts
    11

    Unanswered: using views

    Is there a way inside the design of the view that I can use an if statement to say if the results of a field are t set to Y, if f set to N (not permanently though, just for the recordset)

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    I don't know if this is the best way to do it but I would probably use a union query and do something like....

    select x, y, 'Y' as 'z' from my table where myfield = 't'
    union
    select x, y, 'N' as 'z' from my table where myfield = 'f'

    this should work, but I don't know if it's the best method as I don't use views much.

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Here are three ways to skin that cat. No doubt other people will think up more:

    case field when 't' then 'Y' when 'f' then 'N' else 'U' end
    replace(replace(field, 't', 'Y'), 'f', 'N')
    isnull(nullif(isnull(Nullif(field, 't'), 'Y'), 'f'), 'N')

    blindman

  4. #4
    Join Date
    Feb 2003
    Posts
    11
    what about if the field is blank? how can i set that equal to N?

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    case field when 't' then 'Y' else 'N' end
    replace(replace(isnull(field, 'N'), 't', 'Y'), 'f', 'N')
    isnull(nullif(isnull(Nullif(field, 'f'), 'N'), 't'), 'Y')

    blindman

Posting Permissions

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