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

Thread: query to change column values

  1. #1
    Join Date
    Mar 2001
    Location
    south africa
    Posts
    401

    query to change column values

    Hi ,

    I have two columns in codes table where we have id(number) and code(varchar2)

    I would like to change the if id =1 change it to A and 2 to B and rest change the id from 1..to 13
    in this example I have total 15 and it changes


    Code:
    id	code
    --          -----
    1	99
    2	105
    3	78
    4	66
    5	54
    6	42
    7	30
    8	141
    9	147
    10	153
    11	159
    12	165
    13	171
    14	177
    15	183
    	
    ----------------------------	
    id	code
    --          -----
    A	99
    B	105
    1	78
    2	66
    3	54
    4	42
    5	30
    6	141
    7	147
    8	153
    9	159
    10	165
    11	171
    12	177
    13	183
    I believe I can change 1 and 2 to a and b with decode but not sure how I
    change the order to start from 1 again

    any help is appreciated

    thank you

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    First issue I can see "id" is of the number datatype, can't put a letter there.

    assuming "id" is converted to the varchar2 datatype something like... id = (to_number(id) - 2) would do the trick for the non 1,2 values.
    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
    Mar 2001
    Location
    south africa
    Posts
    401
    thank you

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