How to truncate the value to the nearest integer

Hi friends,
use

Select months_between(:to_date,:from_date) of double that returned as
12.8387096774194
When I pass these parameters in from_date and to_date
10/5/2011-15/4/2010

now I want this value to be rounded to 13
and if the difference is like 0.2322
It should give me 1
If the difference is like 1.6 should give me 2

pls suggest a solution

It looks like you want CEIL:

SQL> with t as (
  2   select 12.838 n from dual union all
  3   select 0.2322 n from dual union all
  4   select 1.6 n from dual
  5  )
  6  --
  7  --
  8  select n, ceil(n) n_ceiled from t
  9  /

              N        N_CEILED
--------------- ---------------
         12.838              13
          .2322               1
            1.6               2

Tags: Database

Similar Questions

  • number rounded to the nearest integer in Excel

    Hello everyone.

    I use an entry in the file of worksheet to export my Excel (csv format) table, but it rounds the number to the nearest integer.

    How can I solve this problem?

    My VI is uploadet

    Thanks in advance

    Orlando


  • How to truncate the output of the field in the column "LONG".

    Hi all

    I have been asked to retrieve all records from a table with a column that has been initially formatted with the format "LONG".

    How can I truncate the output of this area without having to show the Junk characters?

    Very appreciated

    JR

    Wrong forum!

    This forum is ONLY for questions/problems on Sql Developer and your question has NOTHING to do with this product.

    Please mark the thread ANSWERED and repost it in the SQL/PL/SQL forum.

    SQL and PL/SQL

    When you repost you must SHOW an example of what you are wanting to do. You should also explain what you mean by 'LONG Format' - I have never heard such a thing.

  • How to truncate the query

    Hello

    with this sql:

    SELECT c.country_name, l.city
    FROM countries c, locations l
    

    I have 575 lines,

    How can I truncate the output to 100 lines?

    Add this predicate:

    WHERE ROWNUM<=>

  • How to truncate the number

    Hi all,
    I hope if anyone knows a function to truncate the '+ 1' phone number. We have created a new custom field to the value in the phone field. The question we face is the new value, it will contain three new values (Plus 1 and a space) "+ 1".

    Can update us the default value expression while it:
    a. truncate "+ 1".
    b. remove all spaces in the phone number

    Thank you

    PS: I tried TRIM (CONNECTING '+ 1' < phPhone >). But I get an error!

    I would use a workflow (maybe two, depending on whether you need it to operate on events 'new' and 'Edit'). You can use a combination of the IIR, left, and Len to get what you need. For example:

    IIf (left (, 3) = "+ 1", on the right (, Len ()-3),)

    Chris

  • How to find the nearest point to polyline

    Hello

    I find the point closest to my point of view standing on a polyline. I have Oracle Locator installed, but my data is not in a format locator. Is it possible to do using the functionality of the telecommunications service provider with, for example, the polyline and permanent values of coordinates of points in a space variable by calling some localization features?

    Or I must coordinate data in a spatial 'permit' table, create the spatial index, etc. and then call a procedure Locator.

    Tamas

    Luke,

    Thanks for the reference.

    When the data is converted, the Summit nearest to find an object of sdo_geometry could be done this way (of, of course, for the most part):

    select f.vertex_id,f.dist,f.min_dist,f.a_vertex
      from (select p.vertex_id,
                   sdo_geom.sdo_distance(p.the_point,p.a_vertex,0.005) as dist,
                   min(sdo_geom.sdo_distance(p.the_point,p.a_vertex,0.005)) over (order by sdo_geom.sdo_distance(p.the_point,p.a_vertex,0.005) asc) as min_dist,
                   p.the_point,
                   p.a_vertex
              from (select t.id as vertex_id,
                           mdsys.sdo_geometry(2001,NULL,mdsys.sdo_point_type(358615,5407047,null),null,null) as the_point,
                           mdsys.sdo_geometry(2001,NULL,mdsys.sdo_point_type(t.x,t.y,t.z),null,null) as a_vertex
                      from table(sdo_util.getVertices(
                                MDSYS.SDO_GEOMETRY(2002,null,null,MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1),MDSYS.SDO_ORDINATE_ARRAY(362253.9,5409676.63,355608.12,5407615.16,358063.37,5407673.48,355276.53,5407361.08,360471.08,5408880.79,362483.4,5406024.69,362359.16,5408840.11,354570.21,5406219.18,360204.62,5405849.14,359214.51,5408283.5,358761.06,5406683.88,356739.05,5405590.46,358615.79,5407047.29,355978.02,5407326.33,356240.87,5409898.7,363159.35,5405510.46,358588.81,5406536.54,354822.42,5408643.75,357690.2,5408872.57,359839.29,5407253.86,355236.29,5409711.53,355342.54,5407448.87,360290.53,5405111.51,354677.02,5407916.83,361651.27,5409178.26,361730.18,5407553.5,357402.33,5409065.5,361546.51,5407278.41,361915.65,5408942.57,361974.74,5405464.91,357794.3,5406979.33,356106.58,5405481.32,357604.96,5407407.72,360718.31,5406765.8,359745.49,5406568.16,363005.29,5407557.46,355844.01,5407095.47,362749.66,5405041.82,359714.13,5408898.69,354509.69,5406113.6,360041.59,5406204.24,360380.17,5408751.21,356621.4,5409603.06,355156.27,5405401.98,354441.35,5409090.68,356376.45,5407472.81,363877.1,5405582.72,361883.83,5409696.17,356363.41,5406434.53,362078.96,5406617.37,362714.59,5409800.2,362703.49,5408513.33,358317.64,5408170.64,359294.27,5409197.53,360240.93,5406333.84))
                                )) t
                    ) p
            ) f
      where f.dist = f.min_dist;
    

    I hope this helps.

    Simon

  • How to truncate the table using SQLJ

    Here is a snippet of code SQLJ trying to truncate a table before filling with new records.

    However, while the class compiles fine, I get an error PLS-00103 on execution.

    Your expertise is very welcome and necessary for what seems like a simple problem, for which I can't find an answer.

    import java. IO;
    import java.sql. *;

    public class FadsDirListing
    {
    public static getContentsList (String directory) Sub throws SQLException
    {
    *#sql {FADS_DIR_CONTENTS TRUNCATE TABLE}; * - WHY NOT THIS STATEMENT?
    File [] files = new File (directory) .listFiles ();
    for (int i = 0; (file! = null) & & (I < files.length); (++ I)
    {
    File f = files;
    String filName = f.getName ();
    long filSize = f.length ();
    ModDate timestamp = new Timestamp (f.lastModified ());
    String filType = f.isDirectory ()? "D" : "F";

    {INSERT #sql
    IN FADS_DIR_CONTENTS (FILE_SIZE, TYPE_DE_FICHIER, FILE_NAME, LAST_MODIFIED)
    VALUES (: filName,: filSize,: filType,: ModDate)
    };
    #sql {COMMIT
    };
    }
    }
    }

    Thank you for your help - I appreciate it very much.

    Dave

    You must run a command DDL by NDS. If you wrap it in a PL/SQL block and use NDS to run it, it should work.


    BEGIN
    EXECUTE IMMEDIATE "DDL STATEMENT";
    END;

  • How to truncate the table in a pl/sql block

    Hello guys, I'm trying to truncate a table that includes data using a pl/sql block, so if the table has even a single row then the truncate should run. to do this, I wrote the following code


    declare
    number num.
    Start
    Select count (*) in the num from table_name;
    If num > 0 then
    truncate table table_name;
    end if;
    end;

    Now, when I execute the pl/sql block, I get the following error.

    PLS-00103: encountered the symbol "TABLE" when the expected in the following way:

    When I run the truncate without pl/sql command, it runs very well.

    Can someone please where I'm wrong.

    Thank you

    Published by: 969224 on April 23, 2013 08:08

    969224 wrote:
    Hello guys, I'm trying to truncate a table that includes data using a pl/sql block, so if the table has even a single row then the truncate should run. to do this, I wrote the following code

    declare
    number num.
    Start
    Select count (*) in the num from table_name;
    If num > 0 then
    truncate table table_name;
    end if;
    end;

    Now, when I execute the pl/sql block, I get the following error.

    PLS-00103: encountered the symbol "TABLE" when the expected in the following way:

    When I run the truncate without pl/sql command, it runs very well.

    Can someone please where I'm wrong.

    Thank you

    Published by: 969224 on April 23, 2013 08:08

    DDL is not allowed directly within PL/SQL procedures.

    You must (ab) use EXECUTE IMMEDIATE issuing the DDL

  • How to truncate the first part of the ID

    My problem is the following.
    In my application, I create a new field. I want that this field corresponds to the number 6 of the SR N.
    How should I do?
    Sostantially if the SR N. 485218-305439087 it's my field must be 439087 (the last 6 number of N.SR).
    Thank you
    With regard to the Vale

    The expression of the new field should be left ([], 6)

    Cordially Catalina Valadez

  • How Photoshop converts the RGB 16-bit values to 15-bit and 8-bit?

    Can someone please help me understand what rounding of diet or another algorithm is used when Photoshop reduced a 16-bit color 8-bit?

    For example, the two colors (was and B) are the colours of 16-bit swatch taken directly from a file of the ACO:

    A16 = (61603, 60948, 58982)

    B16 = (58326, 57015, 52428)

    Photoshop displays the values of "16-bit" (acutally 15 bits) as well:

    A15 = (30802, 30474, 29491)

    B15 = (29163, 28508, 26214)

    It seems that the 15-bit values are the result of the division by two and rounded to the nearest integer.

    With 8-bit, it's another story although:

    A8 = (240, 237, 229)

    B8 = (222, 227, 204)

    Now, if we divide the 16-bit value by 256, the following:

    A8_float = (240.6, 238,1, 230,4)

    B8_float = (227,8, 222,7, 204.8)

    It's a similar story during the allocation of the 15 by 128 bit values. No system rounding or truncation will get the same answers as Photoshop for 8 bit I see. What I can't work, it's how Photoshop calculates these figures. It's the division of integers, floating point division with rounding or truncation? I'm puzzled. Help, please.

    -> range 32768-65535: (32768 * x + 32767) / 65535

    Not quite dividing by 2, otherwise you miss the white point.

    32768-> 255 range: (255 * x + 16384) / 32768

    With the exception of dithering, it is all simple mathematics.

  • How to get exact values.

    Hi Forum,

    I'm trying to get the page Width and Height of margin as a text in the slug area.

    When I have less pagewidh with pagemargin, I am getting the values in fractions like that.

    for example. 177.43999999.

    When I draw a rectangle box to check the width and height, the spectacle of palette measures exactly like that... 177,44

    How can I get the exact values I see in the measurement palette...

    var myTextFrame = myDocument.textFrames.add ();

    with (myDocument.pages.item (0) .marginPreferences) {}

    Save the current default value of the margin preferences application.

    var myY1 = top;

    var left = myX1;

    var low = myY2;

    var right = myX2;

    Set the default value of the margin preferences application.

    var mWidth = parseFloat (myPageWidth - myX1 - myX2);

    var mHeight = parseFloat (myPageHeight - myY2 - myY1);

    myTextFrame.contents = "Ratio: y = 1.75 x - final size work = (H)" + myPageHeight + "mm (W) x" + myPageWidth + "mm work set at 25% of the final format = (H) 2410mm (W) x 1370mm Live area = (H)" mHeight + "mm (W) x" + mWidth + 'mm'; "

    }

    Thanks in advance for the help...

    Thank you.

    Math.Round () always round to the nearest whole number (integer).  So suggestion of Jarek use Math.round in a particular way... it is not rounded mWidth directly - it is multiplying mWidth by 100, rounded to the nearest integer and then dividing by 100. This gives you exactly 2 decimal places of accuracy.  If you want 1 decimal place, use 10 instead of 100.  If you want 3 decimals, use 1000.

    Point number to a general routine to round off a float to an individual is the number of decimal places:

    rounding to a number of decimal places (tomaxxi)

    Number.prototype.doRound = {function (roundDec)}

    var roundMulit = Math.pow(10,roundDec);

    return Math.round(this*roundMulit) /roundMulit;

    };

    If you put the above code snippet at the beginning of your script, and then in the main part of your script you can just do this:

    mWidth = mWidth.doRound (3);

    If you want to round up more than 3 decimal places.

    As a general rule, you want to only do this in the user interface code, because there is a good chance that the will (in this case mWidth) number of rounding precision, not LOSE GAIN accuracy, when you round to a number of digits after the decimal point. (Explain exactly why this is true, it's a discussion more).

  • How to access the channel values?

    I'm new to scripting language DIAdem.  I TDMS has a group and several channels with String type all.   How to read the first 4 characters of each string values and store into the new channel?  Example of data file attached.

    I tried for the statement in the Script window

    Ch("[1]/result") = Ch("[1]/Frame")

    or

    Ch("[1]/result") = Right (Ch ("[1] / framework", 3))

    All gave me error...

    Hi NiCoder,

    It's the way you read and write individual channel values, but what to do value-by-value is much slower that make them all with a single call to ChnCalculate():

    Set Group = Data.Root.ChannelGroups (1)
    Define FrameChannel = Group.Channels ("Frame")
    Set ResultChannel = Group.Channels.Add ("Result", DataTypeString)
    iMax = FrameChannel.Size
    FOR i = 1 TO iMax
    ResultChannel (i) = Right (FrameChannel (i), 3)
    NEXT ' I

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • How to get the updated values of the loops while they are running

    Hello

    I am trouble with a very basic problem, how to access the updated values of the "loop FOR" during operation?  Basically, the VI I is currently working on two sub vis calls each sub VI has a loop for, and the two screws may or may not work for the same number of iterations. My goal is to read the values in each terminal within the loop of two sub VIs, in primary VI. I tried to do this using Global Variables, but in main VI it will display only the last iteration of the two value sub live. Could someone please tell me whrere I go wrong? Is there any other/better way to do this.

    I appreciate any input on this issue.  

    Pass a reference of the main VI control to the Sub screws.  See attached example.

  • How to read the value of list boxes by iteration in a loop For?

    I have a lot of list boxes on the front of my VI. I want to know how to read the value of this combo with a loop boxes For. The point is that I don't know how to get the reference of each combo box in a loop.

    Any information would be welcome. Thank you!

    su27 wrote:

    I have a lot of combo boxes on the front of my VI [...]

    Be sure to close the references that you have finished with them.

  • How to save the value controls in labview

    Hello
    I want to know how to record the value of controls in the PC. means if I attribute 5 numeric value to a control, he has to stay there even I restart my PC.

    And here is a simple example of using - http://decibel.ni.com/content/docs/DOC-15349

Maybe you are looking for