DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: select in a view that returns constant value

  1. #1
    Join Date
    Apr 2009
    Posts
    10

    select in a view that returns constant value

    I'm trying to create a view that just selects from columns and also returns a constant value based on the data in a column. I can't get it though. Something like this:

    create or replace force view lead_stats (
    accession, value, insurance)
    as
    select a.accession, a.value, ('T' if b.code = 'C' OR 'F' if b.code <> 'C')
    from tableone a, table2 b
    where a.acct = b.acct


    I can't figure out how to get the view to return a T if the b.code field has a C and to return an F if the b.code field contains anything but a C.
    Any ideas are greatly appreciated.
    Thanks.

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    decode(b.code,'C','T','F')
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Apr 2009
    Posts
    10
    Thanks very much, that works perfectly!

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Glad to help.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

Posting Permissions

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


Click Here to Expand Forum to Full Width