Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    76

    Red face Unanswered: Decode for values in a different column

    I am trying to use a decode in column A of a view based on the values in Column B. eg

    A B
    ____
    x U
    x Y
    x U

    If B = 'U' leave 'x' alone in column A. If B is not 'U' than replace value in column A, i.e 'x' to 'z'.
    Please help. Thank you.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Decode for values in a different column

    select decode(b,'U',x,'z') from table;

    For example:
    PHP Code:
    SQLselect enamedeptnodecode(deptno,10,ename,'XXX')
      
    2  from emp;

    ENAME          DEPTNO DECODE(DEP
    ---------- ---------- ----------
    SMITH              20 XXX
    ALLEN              30 XXX
    WARD               30 XXX
    JONES              20 XXX
    MARTIN             30 XXX
    BLAKE              30 XXX
    CLARK              10 CLARK
    SCOTT              20 XXX
    KING               10 KING
    TURNER             30 XXX
    ADAMS              20 XXX
    JAMES              30 XXX
    FORD               20 XXX
    MILLER             10 MILLER

    14 rows selected


  3. #3
    Join Date
    Nov 2003
    Posts
    76

    Thumbs up Re: Decode for values in a different column

    Thank you very much

Posting Permissions

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