Results 1 to 6 of 6

Thread: View advice

  1. #1
    Join Date
    Oct 2010
    Location
    New York Metro
    Posts
    17

    Question Unanswered: View advice

    Hello,

    I would like to create a view in oracle for one of my clients to obtain on a daily basis. However we have different ways of interpreting data.

    For instance, I have row values 1,2,3.. but the client needs to read this as A,B,C

    What would be the best way to approach this?


    Thanks in advance.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Code:
    CREATE VIEW the_unknown_view
    AS 
    SELECT case 
              when the_unknown_column = 1 THEN 'A'
              when the_unknown_column = 2 THEN 'B'
              when the_unknown_column = 3 THEN 'C'
              else 'N/A'
           END,
           other_column
    FROM the_unknown_table

  3. #3
    Join Date
    Oct 2010
    Location
    New York Metro
    Posts
    17
    Thank you for replying.

    What additional steps need to be taken if we are talking about different datatypes?

  4. #4
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >What additional steps need to be taken if we are talking about different datatypes?
    use appropriate datatype conversion functions, like TO_CHAR(), etc.
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by dataman2010 View Post
    What additional steps need to be taken if we are talking about different datatypes?
    My example already converts a number column to a character column.

  6. #6
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    For something so simple, I would use decode

    Code:
    SELECT decode(when the_unknown_column,1,'A',2,'B',3,'C','N/A') other_column
    FROM the_unknown_table
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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