Results 1 to 6 of 6

Thread: SQL 9i

  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: SQL 9i

    Hi

    Is there a way to have a different string 'B' output by a query when it encounters a string 'A' in a column?

    E.g.,
    Code:
     in a column whereever it says 'CAR', I'd like the output to give 'REDCAR'.
    Regards
    Shajju

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    REPLACE function?

  3. #3
    Join Date
    Aug 2008
    Posts
    464
    Thanks...I will check Replace out. However, I also used the CASE statement successfully but it turns out that the requirement is to have the query return a different string depending on the input of 2 columns.

    Code:
    CASE OBJECTID
    WHEN 'ABC' THEN 'XYZ'
    END SITE
    I tried

    Code:
    CASE OBJECTID,AAA
    WHEN 'ABC103','AAA1' THEN 'XYZ103'
    END SITE
    But it's not worked!

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Code:
    case
     when objectid = 'aaa' and othercolumn = 'bbb' then 'xyz'
     else 'foo'
    end

  5. #5
    Join Date
    Mar 2007
    Posts
    623
    Quote Originally Posted by shajju View Post
    But it's not worked!
    Because it is syntactically incorrect. What about searching for it in SQL Reference, available with other Oracle documentation books e.g. online on http://tahiti.oracle.com/
    CASE expression for 9iR2 is described here: http://download.oracle.com/docs/cd/B...5a.htm#1033394

    Alternatively you may nest CASE expressions:
    Code:
    CASE OBJECTID
    WHEN 'ABC103'
    THEN CASE AAA
         WHEN 'AAA1'
         THEN 'XYZ103'
         END
    END SITE

  6. #6
    Join Date
    Aug 2008
    Posts
    464
    Many Thanks guys!

Posting Permissions

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