Displaying all numbers with 2 decimal places

Hi All,
We have a requirement in our code where we want that all numbers must be diplayed with 2 decimal places.
Eg: If a number is 21.234 then it should be displayed as 21.23
If a number is 21.289 then it should be displayed as 21.28
If a number is 21 then it should be displayed as 21.00
Can anyone please help me how to do it in a SQL query.
Regards,
Shruti

Hi, Shruti,
This shows a couple of things you can do:
COLUMN     trnc     FORMAT     999999.99
WITH     got_x     AS
     SELECT     empno / 1000     AS x
     FROM     scott.emp
SELECT     x
,     TO_CHAR (x,            '999999.99')     AS tc
,     TO_CHAR (TRUNC (x, 2), '999999.99')     AS trnc_tc
,     TRUNC (x, 2)                              AS trnc
FROM     got_x
;Output:
`        X TC         TRNC_TC          TRNC
     7.369       7.37       7.36       7.36
     7.499       7.50       7.49       7.49
     7.521       7.52       7.52       7.52
     7.566       7.57       7.56       7.56
     7.654       7.65       7.65       7.65
     7.698       7.70       7.69       7.69
     7.782       7.78       7.78       7.78
     7.788       7.79       7.78       7.78
     7.839       7.84       7.83       7.83
     7.844       7.84       7.84       7.84
     7.876       7.88       7.87       7.87
       7.9       7.90       7.90       7.90
     7.902       7.90       7.90       7.90
     7.934       7.93       7.93       7.93Column x is the number, as SQL*Plus displays it by default. Note there are as many digits after the decimal point as are needed.
Column tc shows how TO_CHAR can format the number, with exactly 2 digits after the decimal point. This automatically rounds the number to the nearest multiple of .01, so on the first row (for example) 7.369 gets displayed as 7.37.
user11272043 wrote:
... If a number is 21.289 then it should be displayed as 21.28You (apparantly) always want the number rounded toward 0, so column tc isn't quite what you want.
Column trnc_tc is exacly what you requested, with the numbr rounded toward 0 (when any rouning is necessry) and 2 digits after the decimal point.
Column tc is also exactly what you requested, but it uses SQL*Plus formatting rather than SQL. Also, column trnc is a NUMBER, while column trnc_tc is a VARCHAR2, because TO_CHAR, as its name hints, returns a VARCHAR2.
The SQL*Plus command
SET   NUMFORMAT  999999.99changes the default format for all number columns. If you use this, you can override it for individual columns by using TO_CHAR (since it returns a VARCHAR2, the NUMFORMAT doesn't apply),or a COLUMN command. Also, if you use SET NUMFORMAT 999999.99, you'll still have to explicitly TRUNC every number, or else 21.289 will come out as 21.29, not 21.28.

Similar Messages

  • BEx Analyzer displays wrong number of decimal places after implementing BW patch

    Hey folks,
    we patched our BW 7.31 from PL10 to PL15 last weekend and now we got some issue with the number of decimal places shown in BEx Analyzer 7.x.
    One example for KF X
    Settings Info Object X
    Decimal Places:                         Not defined
    RSRT - Display X
    Shows 3 decimal places
    Query Designer Settings using KF X
    Number of Descimal Places:     0  [Use Default Settings: NO]
    BEx Analyzer Properties for KF X
    Decimal Places:                         0
    Resulting in BEx Analyzer workbook shows 3 decimal places instead of 0!
    Anyone with an good idea about that?
    Thanks,
    Andreas

    Hi Andreas,
    Have you used the list calulation like "Calculate Result As Average" or "Calculate Single Values as normalization of result" in the relevant key figures?
    For "Calculate Single Values as normalization of result",iIt is the known design that it is always displayed with three decimal places for normalized values, and the setting in Query Designer for
    decimal place doesn't take effect.
    For "Calculate Result As Average", the following note maybe relevant.
    2096911 - Decimal places in query result is wrong, if average is used and display precision is set to less than 3, it will always show 3 decimal places.
    Another clue is to check if the key figure is a Quantity type with unit, and what's defined in table
    T006 field ANDEC for this unit.
    Hope this helpful.
    Regards,
    Ceciclia

  • Download amount value without decimal place but element with decimal place

    Hi all,
    to display the amount without decimal places in classic report, i can use this way which is wa_wrshb NO-ZERO CURRENCY wa__waers.
    may i know,
    1) how to display amount in ALV where amount value (which using dmshb/wrshb) has no decimal place like JPY?
    2) what should i do if i want to download the amount value which field using dmshb or wrshb that the value has no decimal place like JPY?
    Thanks

    Hello,
    You can display the ALV output according to the decimal point in the currency.
    When creating the field catlog for the amount field add the currency parameter also.
      wa_fieldcat-fieldname     = <amount_field>.
      wa_fieldcat-tabname       = <output_table>.
      wa_fieldcat-seltext_l     = <column_heading>.
      wa_fieldcat-outputlen     = p_olen.
      wa_fieldcat-currency      = wa_waers.              " This will work same as CORRENCY wa_waers
    Regards
    DKS

  • PO print preview displays incorrect setting in decimal places

    Dear Experts
    Please help me on the following condition.
    I have a problem in print preview of a PO. It displays the incorrect setting for decimal place in currency.
    It shows USD 1.404,00 whereby the amount should be USD 1,404.00
    This only happens to a certain vendor that is doing PO for the first time from that country
    Example:
    I'm creating a PO for vendor 123. Vendor 123 is located in country A. No PO has been created for any
    vendor in country A before. When I saved my PO, in print preview, the decimal setting is not correct.
    But when I'm creating another PO, for vendor 234. Vendor 234 is located in country B. There have been
    several POs created for vendors in country B before. When I saved my PO, in print preview, the decimal
    setting is correct.
    Both vendor 123 and vendor 234 is using currency of USD.
    Is there any other setting with the vendor master in regard with the currency decimal setting for each
    country for the vendor? Or something that I've missed out?
    Diagnosis:
    I've checked with the user profiles->default-> decimal notation. It displays 1,234,567.89 correctly
    I've also run OY04, but the decimal setting is correct.
    Thank you
    Regards
    Syukri

    this has nothing to do with print preview, it is just basic country setting (OY01) how a quantity and value is written on a PO to a vendor is country xyz.
    German uses to comma to seperate decimals, while USA uses the point to seperate decimals
    this would be the German version 1.404,00, and this the US version:: 1,404.00
    so if an American sends a PO to a German vendor, then the document will show 1.404,00 so that the German can understand that he wants 1404. (and not 1000 times less)

  • Select amount field of a table with decimal place of 3rd value grater than 0.

    Select all the reord  in a table with amount decimal place of 3rd value grater than 0.

    Can you show the sample data + desired result?
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Problems with decimal places and formatting

    Hi , we are having problems with an add on running on different localization companies. Decimal places separatd by "," differ from other localizations. We dont know if this is a SQL collation setting or somethng related to code or requirements to run add ons on different servers and languages.
    Any ideas??
    Thanks

    Hello
    Follow up with this thread:
    [Re: How to get the numeric value of DocTotal from UI API]
    Regards,
    J.

  • Comapre numbers with decimal

    Hi,
    I am using CP 5 advanced actions - conditional actions, trying to show the less number in the caption. However, seems CP assumes that a number with decimal is less than the number itself. For example, we have 5875.198.148 and 5875, then 5875.198.148 will be taken as the less number.
    Best,
    Ya

    Hello,
    I just checked this and for me the condition is evaluated correctly. Could you post perhaps a screenshot of your advanced action? This was my work flow:
    created two user variables, one with a decimal value, the other with the same value but only the integer
    had two rectangles, initially invisible, one for correct result, one for incorrect
    on entering the slide I triggered a condition to compare the variables and show the appropriate rectangle; all worked fine
    Just a tip: try if it works if you put the values themselves in the condition, like  IF   15.5 is greater than 15 
    BTW: you seem to have two decimal points? That will not work, I suspect this will not be treated as a value because it isn't a value
    Lilybiri

  • Change IDR currency with decimal place

    Dear Guru,
    Currently in my SAP env, IDR currency setting is set with 0 decimal place.(No decimal Place). However, I have user requirement to change the setting from zero to 2 decimal place. Meaning to say, to have IDR currency maintain in 2 decimal place. What is the effort and is this a big change to the system ? is this change workable ? How will this impact the existing historical data which store IDR amount with no decimal place ?
    Hope to hear from you.
    Regards
    Andrew Tay

    Dear Guru,
    Thank you for your replied. I totally agreed with you, currently my SAP system can maintain up to 15 digits with no decimal place. Beside this digits isues, is there any other areas affected ?
    Thanks in advance.
    Regards
    Andrew Tay

  • Set html text doesn't display all numbers

    Ok, so that one is a strange.
    I was playing around with the scroll event on a rectangle (not on Stage) and wanted to display the scroll value
    So code looks like this :
    Symbol.bindElementAction(compId, symbolName, "${_Rectangle}", "scroll", function(sym, e) {
    var ScrollDuHaut = e.currentTarget.scrollTop;
    console.log(ScrollDuHaut);
    sym.$("Text").html(ScrollDuHaut);
    But once in a while, the Text element doesn't show up, although just the numbers changed…
    Any clue is welcome : Weird display of scroll

    Hi,
    I tested your files using Firefox 20 (beta), Opera 12.5 and Internet Explorer 10. It runs fine.
    Only webkit browsers fail to return correctly sym.$("Text").html()

  • Calculated field with decimal place

    Hello,
    if I create calculated field in a table using formula e.g., ColumnName/ 60, where format of ColumnName is INT (total ammount of minutes)  in order to get hours, I get only integer part, not decimal. E.g., 80 (minutes)/60 =1.3333 but, in calculated field
    I see only 1 hrs without possibility to change format of the field.
    Can calculated field be used on this way? (My wish  is to get 1.3 in that field)
    How?
    Thanks

    Of course the calculated field/column can not be an INT, if it is then change that.
    Does something like this work?CAST(ColumnName/60 AS Decimal(10,2))

  • Displaying an integer to 2 decimal places

    celsius = 5.0 / 9.0 * (fahrenheit - 32.0);
    lblCelsius.setText(" " + celsius);
    How do I display celsius to 2 decimal places as currently 70 degrees F = 21.11111111
    Thanks

    Check out java.text.Format and java.text.NumberFormat

  • Query to find records with more than 2 decimal places

    I have written the below query to find records with more than 2 decimal places, but it is returning records with decimal places 1 & 2.
    The datatype of the AMT column is NUMBER (without any precision).
    SELECT amt  FROM amount_table
    WHERE substr(amt, instr(amt, '.')) LIKE '.%'
           AND length(substr(amt, instr(amt, '.') + 1)) > 2Output:-
    AMT
    *41591.1*
    *275684.82*
    *64491.59*
    *3320.01*
    *6273.68*
    *27814.18*
    *30326.79*
    131.8413635
    162.5352898
    208.5203816
    8863.314632
    22551.27856
    74.716992
    890.0158441
    2622.299682
    831.6683841
    *1743.14*
    2328.195877
    3132.453438
    5159.827334
    3.236234727
    37.784
    Thanks

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    create table amount_table
      LINE_NUMBER        NUMBER not null,
      FEE_AMT            NUMBER not null
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (60208, 41591.1);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (60213, 275684.82);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (60238, 64491.59);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (63026, 3320.01);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (59906, 6273.68);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (83111, 27814.18);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (83114, 30326.79);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112395, 131.8413634682);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112399, 162.5352898104);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112402, 208.5203815738);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112403, 8863.3146321954);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112406, 22551.2785551322);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112407, 74.716992);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112410, 890.015844079);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112411, 2622.2996817048);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112414, 831.6683840698);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112415, 1743.14);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112418, 2328.1958771886);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112419, 3132.4534379886);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112422, 5159.8273341686);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112423, 3.2362347266);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112426, 37.784);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112427, 198.7423503696);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112430, 0.7220848332);
    insert into amount_table (LINE_NUMBER, FEE_AMT)
    values (2112433, 12.4149375254);

  • Need to trim decimal Places in data pulled in Financial report

    Hi All,
    We have a Financial report in which in partcular column, data is being pulled by the formula :
    <<CellText("Grid1", Cur, C(A), 1)>>
    Some cells in that column contains only text comments, some cells having numbers only.
    Issue is with the numbers. Numbers when pulled in FR are being dispalyed upto 6 decimal places, i.e. 1234 is displayed as 1234.000000.
    So if somebody can suggest how can we modify the formula so that we can display the numbers without decimal values. i means , numbers being pulled are displayed as 1234 only not like 1234.000000.
    Thanks,
    Satish

    Hi there,
    You can use the function Trunc(xxxxxxx, 0) where xxxx is your retrieved value which is considered as numeric.
    However, if I were you, I would concentrate on how to resolve the issue with the smartview submission.
    Regards,
    Thanos
    One Truth about...

  • Decimal places in standard input schedule templates

    Hi Gurus
    I have created some input schedules using standard template. User here will be entering some values in 2 decimal places (like 1.25) but when I enter any values in the cells, it automatically round off the values and displays values without any decimal places.
    I have tried changing the formats in Format control panel by changing the DATA / DEFAULT 's PATTERN / ALL for ROWs but it did not help.
    Please help how to resolve this.
    Cheers
    Swathi

    Hi nilanjan,
    Thanku, I resolved the issue using Format Range option with the below code
    CRITERIA    EVALUATE IN  FORMAT     USE     PARAMETERS    APPLY TO
    INPUT          ROW                1234,56      ALL                --                   DATA
    Thanku

  • Decimal Places In VDT Measures

    hi experts,
    i  have a small problem with decimal places.
    i'm using the UMC_CPM_STRAT to customize my Measures and VDTs
    i have created measures using 0QUANTITY and defined 0.00 in the decimal places field.
    after a while i have changed all the measures of the tree to 0 in decimal places
    now i've changed back to 0.00 but my measures do not change
    when using the UMV_PRES my measures has no dec' places like it is still using 0 and not 0.00
    have i forgotten something along the way?
    need your help
    thank you,
    Or.

    hi all,
    i was able to solve the problame of the decimal places display in my vdt.
    first i have changed it in tge measure attr' in the transaction UMC_CPM_STRAT -> Measures
    since i am working with a bps definitions i have found that i need to change it also in the transaction BPS0 -> Planing Area -> Planing Level -> ad-hoc Package -> Menual Planning -> change layout
    in the layout def's you can choose the number of dec' places.
    for your knowledge.
    Best Regards,
    Or.

Maybe you are looking for

  • Nokia 603 SMS thread view problem

    Hi All, My nokia 603 is unable to display the message in thread view. whenever the SMS is sent or recieved it will show some random integers. but if i enter to the folder view I am able to view the entire message. This is happening all of a sudden wi

  • Call a URL which is a Javascript

    Hi All. I know we CANNOT call javascript in Web dynpro abap. I also know we can call a URL via calling external window and passing the URL. We needed a functionality which requires a small piece of javascript code to be executed on click of any butto

  • GG on Physical Standby database

    Hi All, Could anyone please let me know whether we can create extract of physical standby database Archive logs? This is oracle 9i physical standby database and I want to configure the primary extracts on standby database instead of primary productio

  • Problems opening edit mode from Main Menu in Elements 8

    Photoshop Elements won't open in edit mode after the main menu comes up fine. The other choice, and I forget what that is because I never use it, DOES open up. I use Lightroom for 98 percenr of PP of photo files. I DO use Elements once in a while for

  • When does iOS 7 come out in Australia?

    does anyone know what time iOS 7 comes out in Australia? and is it the 18th for America or Australia?