Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2012
    Posts
    37

    Unanswered: Dividing the number by 100

    Is it possible in oracle that when i give the number
    lets say 345 it should give the result by 3.45(means it should divide the number by 100 at back end)
    I should not do it manually. I just give the number and it should give me the result.

    like select 223 from dual
    when it execute this statement it should give me 2.23

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    what's wrong with
    Code:
    select 223 / 100 from dual
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Mar 2012
    Posts
    37
    I have the constraint. because i have to read the source file..
    Some type of conversion if there possible

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Or create a function (but that's really an overkill here):
    Code:
    SQL> create or replace function f_div_by_100 (par_num in number)
      2    return number
      3  is
      4  begin
      5    return (par_num / 100);
      6  end;
      7  /
    
    Function created.
    
    SQL> select f_div_by_100(223) from dual;
    
    F_DIV_BY_100(223)
    -----------------
                 2,23
    
    SQL>

  5. #5
    Join Date
    Mar 2012
    Posts
    37
    Any internal Conversion is not there. like we do normally
    number to varchar, date etc.

  6. #6
    Join Date
    Mar 2007
    Posts
    623
    Just to paraphrase your question:

    Is it possible in calculator that when i give the number
    lets say 345 it should give the result by 3.45(means it should divide the number by 100 at back end)
    I should not do it manually. I just give the number and it should give me the result.

    like typing 223 on its buttons
    when it processes these strokes it should display me 2.23

    Now seriously: what problem are you really trying to solve?

  7. #7
    Join Date
    Oct 2002
    Location
    Cape Town, South Africa
    Posts
    253

    Question

    Quote Originally Posted by goodman2253 View Post
    Any internal Conversion is not there. like we do normally
    number to varchar, date etc.
    The concept I think you are referring to is the NLS environment which implicitly convert the formatting of values when outputting to text.

    And no, there is no number format setting like there is for dates. You can only change the decimal and group characters. But you can't change two hundred and twenty three into 2,23.
    See the Orale documentation on Setting Up an NLS Environment.

Posting Permissions

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