Results 1 to 3 of 3

Thread: Update field value to decimal

  1. #1
    Junior Member
    Join Date
    Apr 2008
    Answers
    1

    Update field value to decimal

    Suppose there is a field salary and the value is 9125462, the rightmost number(2) indicates the number of values after decimal. We have to update the same for all records. Eg for above number 9125.46 should be updated, for 452861, it should be updated as 4528.6. How will you do this?


  2. #2
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: Update field value to decimal

    SQL> SELECT * FROM XXX;

    A
    ---------
    9125462
    452861

    SQL> UPDATE XXX
    2 SET A = (TRUNC(A/100)||'.'||MOD(A,100)) ;

    2 rows updated.

    SQL> SELECT * FROM XXX;

    A
    ---------
    91254.62
    4528.61


  3. #3
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Update field value to decimal

    use this in ur updation
    select decode(substr(&num,length(&num)),2,substr(&num,1,length(&num)-1)/100,1,substr(&num,1,length(&num)-1)/10,3,substr(&num,1,length(&num)-1)/1000) from dual


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact