Decimal places in a query

Hi all,
How to set in a query the decimal places in 3?
For example:
1,006
Edited by: Philip Eller on Jun 18, 2008 9:23 AM

Hi all,
I've got the same problem. I only want to see the 'Totaal HL' with 6 decimal places. I tried this:
DECLARE @M INTEGER, @Y INTEGER
SET @M = 4
SET @Y = 2008
SELECT
  T1.U_ItmAccg AS 'Accijnsgroep',
  T3.U_T_Dscr AS 'Omschrijving',
  'Factuur' AS 'Doctype',
  ((SUM(T1.Quantity * T2.SVolume * (CASE T1.UseBaseUn WHEN 'Y' THEN 1 ELSE T2.NumInSale END))/100) * 1.000000) AS 'Totaal HL',
  T3.U_T_Tarief AS 'Tarief',
  ((SUM(T1.Quantity * T2.SVolume * (CASE T1.UseBaseUn WHEN 'Y' THEN 1 ELSE T2.NumInSale END))/100) * T3.U_T_TARIEF) AS 'Af te dragen accijns',
  0 AS 'Terug te vorderen accijns'
FROM [dbo].[OINV] T0
      INNER JOIN [dbo].[INV1] T1 ON T0.DocEntry = T1.DocEntry
      INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
      INNER JOIN [dbo].[@ACC_ACCGRP] T3 ON T2.U_AccSrt = T3.Name
      INNER JOIN OCRD T4 ON T0.CardCode = T4.CardCode
WHERE T4.Country = 'NL'
      AND MONTH(T0.DocDate) = @M
      AND YEAR(T0.DocDate) = @Y
GROUP BY T1.U_ItmAccg, T3.U_T_Dscr, T3.U_T_TARIEF
UNION
SELECT
  T1.U_ItmAccg AS 'Accijnsgroep',
  T3.U_T_Dscr AS 'Omschrijving',
  'Creditnota' AS 'Doctype',
  ((SUM(T1.Quantity * T2.SVolume * (CASE T1.UseBaseUn WHEN 'Y' THEN 1 ELSE T2.NumInSale END))/100) * 1.000000) AS 'Totaal HL',
  T3.U_T_TARIEF AS 'Tarief',
  0 AS 'Af te dragen accijns',
  ((SUM(T1.Quantity * T2.SVolume * (CASE T1.UseBaseUn WHEN 'Y' THEN 1 ELSE T2.NumInSale END))/100) * T3.U_T_TARIEF) AS 'Terug te vorderen accijns'
FROM [dbo].[ORIN] T0
      INNER JOIN [dbo].[RIN1] T1 ON T0.DocEntry = T1.DocEntry
      INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
      INNER JOIN [dbo].[@ACC_ACCGRP] T3 ON T2.U_AccSrt = T3.Name
      INNER JOIN OCRD T4 ON T0.CardCode = T4.CardCode
WHERE T4.Country = 'NL'
      AND MONTH(T0.DocDate) = @M
      AND YEAR(T0.DocDate) = @Y
GROUP BY T1.U_ItmAccg, T3.U_T_Dscr, T3.U_T_TARIEF
Can you help me? Thank you in advance!
Greetz

Similar Messages

  • Decimal places in Query generator

    Hi All,
    I am observing a weird behavior in Query generator's execution of a simple sql query. the query is :
    Select 0.002834
    now, in the general settings - display - amounts , I put the decimal value as 4 or 6,  then only it prints 0.0028 or 0.002834.
    else it prints 0.00 (if the decimal place is 2). it should ideally have nothing to do with the display of amount. any idea?
    (the effect is shown only after you change the decimal display, update it and close and reopen the SAP application.
    Thanks,
    Binita
    Edited by: Binita  Joshi on Apr 12, 2010 4:03 PM

    Hello Binita,
    >I have tried converting it to numeric(19,4) and numeric(19,6) but still the result was same.
    Check your decimal places settings in
    \Administration\System Initialization\General Settings\Display tab
    Check the following values:
    - Units (For meaurement)
    - Decimals in Query
    Now let' s say,
    - Unit set to 6 decimal places
    - Decimals in Query set to 2
    run the following query in query generator:
    select cast(0.000245 as decimal(19,6))
    result will be
    0.00
    run the same query as FMS on item master data in any measurement field (lenght)
    select cast(0.000245 as decimal(19,6))
    result will be
    0.000245
    Now set the - Decimals in Query set to 6 on  \Administration\System Initialization\General Settings\Display tab
    run the following query in query generator:
    select cast(0.000245 as decimal(19,6))
    result will be
    0.000245
    This is a normal habit of SAP B1 rounding engine / displaying engine.
    Regards
    J.

  • Decimal places in a simple select query

    Hi , I've a very basic query for you. I'm running the Select statement below, and want the Area to be just two decimal places. Is there a simple way of doing this ?
    I'm having to compare the difference in accuracy between area calculations in Oracle Spatial and MapInfo to some very sceptical users, and they want to know if we're going to be getting 'vastly' different results.
    (The tolerance is set to 0.5 mm in this instance, as we're using Ordnance Survey MasterMap to derivve our spatial objects).
    select sssi_name, sdo_geom.sdo_area (geoloc, 0.0005)
    from SSSI
    Many Thanks,
    Bruce

    Do you mean simply the following?
    select
        sssi_name,
        round(sdo_geom.sdo_area(geoloc, 0.0005), 2)
    from SSSI

  • B1 Query returning truncated decimal places when the CASE statement is used

    Hi All,
    Perhaps this is a friday thing.
    In B1 the price setting is for 5 decimal places. I have a query the run a business process looking at the data in the Special Prices Tables. When I run the Query in SQL, the output show the correct number of decimal places. However, when the Query is then  saved and run in B1, the output is truncated to 2 decimal places. Any ideas as to how I can prevent this for happening?
    T0: Points to teh OSPP Table
    T1: Points to the OSP1 Table
    The portion of the query causing the issue is as follows:
    case
       when (T1.price is not null) then
             T1.price
       else
           T0.price
    end

    Hi Earl
    Seems you are right, I have tested with a few different formats and each time get a 2 decimal result. In SQL help I found the following which may explain why:
    Result Types
    Returns the highest precedence type from the set of types in result_expressions and the optional else_result_expression. For more information, see Data Type Precedence (Transact-SQL).
    Even tried it in SQL with a stored procedure storing to a temp table and it shows the full decimals, but executing the SP in SAP Business One results in 2 decimals again.
    This is indeed a strange occurrence and I a not sure how you are going to solve it! You can use NVARCHAR for example except that it right aligns the values returned, but at least it doesn't drop the decimals.
    Kind regards
    Peter Juby

  • 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);

  • Query regarding decimal places for currencies

    Dear all,
    SAP standard allows 2 decimal points as default for any condition value. However, based on the entries in TCURX table we can set number of decimal places with reference to specific currencies.
    In our system there is no entry in TCURX table against USD currency. Still the system is taking 3 decimal places against the expected 2 decimal places.
    Is there somewhere hardcoded this for US or are they any additional settings impacting this? Please help
    Regards,
    Rajesh

    Hi All,
    I have been trying to set 3 decimal places. I got the reference to Note # 38881.
    This is what I did:
    1. Create a new currency US$ and set the decimal places to 3
    2. Maintained the prices using VK11.
    3. Changed the customers' sales area currency to US$
    But when I created the sales order although the system determined the prices in 3 decimals i got the following information message which keeps on showing during the entire sales order creation:
    Pricing error: Mandatory condition ZMAC is missing
    Message no. V1801
    Details are as below:
    The obligatory condition ZMAC does not exist. The document is therefore considered to be incomplete from the point of view of pricing.
    The cause can be, for example, that a condition record does not exist for condition ZMAC or that a field overflow has occurred when the condition rate was calculated.
    Procedure
    Check why the condition could not be found. Use the pricing analysis function on the pricing screen to do this. If necessary, add the missing condition manually to the document.
    I believe I am missing some configuration that should be done in pricing, not sure what. As this question has been flagged answered, hope someone would be able to help me.
    Thanks & Regards,
    Rajesh Singh

  • Can not change the number of decimal places in the normalization of result

    dear all
        i want to see the proportion of some data, for example, the income of May is 300, and the total income is 1000, i need to display it like 33.33% . so i set the
    Calculate single values as normalization of result, and then it display 33.333%, i like to display only two number of decimal places, so i set the number of decimal places as 0.00, but i doesn't work, it still display three decimal numbers.
        maybe you say i can use the percentage function like %CT %GT %RT, but i need to allow external access to my query, so the i can not use those functions.
        can somebody helps me ? your advice is appreciated.

    hi,thanks for your advice, but that doesn't suit for my problem.
    before i set the normalization of result, i can change the decimal values. After that i cann't.
    In your thread, someone proposes use the T-code OY04. but this wouldn't help. As i change to other key figure, such as user quantity, when i set normalization of result, it still display 3 decimal values.
    i think the point maybe lie in the normalization of result. please advise... thanks...

  • Key figure, number of decimal places are not showing in report output

    Dear experts,
    At cube level PO qty value is getting 0.010 where as in bex report output of PO qty showing as 0. I have chosen decimal places as 0.000 in key figure additional properties tab. In query designer also I have chosen no of decimal places as 0.000 in display propertiesu2026please help me out. How can I get 0.010 value in report o/p.
    Thanks in advance.
    Srivalli.

    Hi,
    Try to run the query in RSRT. CHeck if you are getting the same output. Also make sure that in the reports all the filters are same as you have applied in the info -cube to see the data.
    - Jaimin

  • U261B An Issue due to 3 Decimal Places in Percentage - Help Required

    I've an Issue in BEX report output, which is like when I try to create a 'Percentage' computation on a Key Figure Value, I'm getting 3 decimal places as 'default' output.
    The 'Calculations' settings I made for this KF is
    > Calculate Result as ... Nothing Defined
    > Calculate Single Values as .... Normalize According to Next Group Level Result
    > [✔] Apply to results
    > Calculation Direction - Along Rows
    ☹  I ran SAP_RSADMIN_MAINTAIN and set object 'IGNORE_T006_ANDEC' to the value 'X' - Not woking! Should I choose Update/Insert/Delete??
    ☹  T006-ANDEC & T006-DECAN for '%' has 0 decimal places only. Am I checking the correct stuff?
    ☹  OSS note 866505 not helpful for my issue. BW 7.0 Stack
    I'm getting my output as expected, but the only worrying factor is 3 decimal places due to the 'Calculations'. I'm unable to resolve using existing methods. Should I raise an OSS Note for this?
    Please help...

    Hi, I posted a message to SAP on this topic and got an explanation - it is a behaviour that cannot be changed in certain cases:
    it 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. This is because that normalization
    changes the number dimension of this structure element.
    You may refer to below notes about more details.
    > 869135 Decimal places and scaling for "Calculate Single Values As"
    You cannot set the number of decimal places or the scaling for some
    columns or structural components.
    For 2: Some "Calculate As" functions change the number dimension of a
    KID. In this case, the scaling and the number of decimal places set for
    the KID are no longer relevant. In this case, the system ignores the
    original setting and selects a setting that corresponds to the new
    number dimension. This cannot be overwritten. The following functions
    are affected:
    Calculate Single Values as Scale to Result, Overall Result or Query
    Result: Scaling 1 and three decimal places.
    > 501930 Number of decimal places setting is not applied
    As a result, normalized values resulting from the list calculation are
    displayed with three decimal places and without scaling by default.
    best regards, thom

  • Difference of decimal place in SAP R/3 and BW

    Hello SAP experts,
    I am extracting purchasing data from SAP R/3 using datasource 2LIS_02_SCL.
    In BW I see a difference of one decimal place.
    In RSA3  amount is shown as 17.350,00
    Whereas in PSA above value is displayed as 1.735,000
    Decimal notations are same in both R/3 and BW.
    Please help me to understand the reason behind difference in values.
    Thanks and Regards
    Shilpa

    Hello All,
    The issue is resolved. The difference in Amount is due to different decimal configuration settings in TCURX table in both R/3 and BW. Ideally these settings should be same in R/3 and BW. If decimal settings doesn't match misalignment has to be taken care of either in ETL or during query design.
    Thanks and Regards
    Shilpa

  • Trunc 2 decimal places

    I have a report that has the option of dispalying pdf or excel. I have the pdf version working fine but i am having a little trouble on the excel version. I have a grand total and department total. Basically I need help formating two decimal places. Both dept_total and grand_total are numbers that both display. I have another column that displays what percent of the total is from each dept.It currently returns a number such as 10.23383547957459973 which i need to display as 10.23 How can i incorporate the trunc function into this code?
    ...to_char((dept_total/grand_total) *100)
    The query looks similar to this.
    select
    to_char(a._grand_total)
    ,to_char(a.dept_total)
    ,to_char((dept_total/grand_total) *100)
    from(
    select sum(xxxx) grand_total,
    sum(xxxx) dept_total
    from table)a

    Use ROUND:
    select to_char(round(10.23383547957459973, 2)) from dual;
    10.23

  • Trunc percentage two decimal places

    I have a report that has the option of dispalying pdf or excel. I have the pdf version working fine but i am having a little trouble on the excel version. I have a grand total and department total. Basically I need help formating two decimal places. Both dept_total and grand_total are numbers that both display. I have another column that displays what percent of the total is from each dept.It currently returns a number such as 10.23383547957459973 which i need to display as 10.23 How can i incorporate the trunc function into this code?
    ...to_char((dept_total/grand_total) *100)
    The query looks similar to this.
    select
    to_char(a._grand_total)
    ,to_char(a.dept_total)
    ,to_char((dept_total/grand_total) *100)
    from(
    select sum(xxxx) grand_total,
    sum(xxxx) dept_total
    from table)a

    Hi,
    Since you're calling TO_CHAR anyway, you can add a 2nd argument, specifying two decimal places:
    select
         a._grand_total
    ,     a.dept_total
    ,     to_char ((dept_total/grand_total) *100,       '999999999.99')     AS pct
    from     (
             select  sum (xxxx) grand_total,
                      sum (xxxx) dept_total     -- Why have two copies of the same value?
             from    table
         )a If you're not using a 2nd argument, why use TO_CHAR at all in this query?
    This will round the value, not truncate it. That is, if the value is 10.23<b>5</b>83547957459973, it would display '10.2<b>4</b>', not '10.2<b>3</b>'. If you always want to round toward 0 (rather than to the nearest multiple of .01), then use TRUNC.

  • Increase XL Reporter's Decimal Places to more than 2

    Hi All,
    Can anyone advise on how to increase the default decimal places in XL reporter to be more than 2?
    The figures i retrieved from SAP Financial Template for the stock account is 1234567.81 but XL report shows it as 1234566.76.
    Does showing a differences of 0.05 value.
    I did a sum for the stock account from JDT1 using query. it is also showing me 1234567.81.
    So, I am assuming that XL reporter is using 2 decimal places by default.
    Please help my balance sheet is not balance.
    Regards
    Jessie

    I found that there is a SAP Note written to increase the decimal in SAP XL Reporter.
    See SAP Note 896207.

  • Yielding the desired number of decimal places using the AVG function in t-sql

    Hello again.  Confused retired hobby coder having trouble setting up a scalar-valued function to return the desired number of decimal places from a AVG query.
    Whenever I run the following script I get the number of decimals I desire:
    Using the above I created a scalar-valued function as follows:
    Running this function as: SELECT [dbo].[TestHCIPartial] (1,3)  my return is -7.
    Can you help me with the function causing it to yield the answer to 6 decimal places?
    Thanks and regards, Minuend.

    You've not specified precision and scale in UDF return type. So you're leaving it to server to interpret it based on default settings
    If you want exactly up to four decimal places tweak udf as below
    ALTER FUNCTION..
    RETURNS decimal(20,4)
    AS
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • Decimal places for formula variable

    Hello,
    I have created a formula variable of type manual entry and type number. I'm multiplying it to an amount. The problem is that the user is unable to enter a decimal place value.
    eg:
    cannot enter 0.5 or 0.05. the query regards it as 5 (converts 0.5 or 0.05 to 5)
    when i enter 5.1, it converts it to 51
    when i enter 51.11, it converts it to 5.111
    when i enter 51.111, it keeps it the same and does not change it.
    Is there a setting that i need to change in the query or the fomula variable? I need the variable to accept decimal values with out changing the decimal places.
    Regards,
    Sameer

    This was an issue with the number format setting for the user.
    His setting was 1.000.000,00 and he was trying to enter it in this format: 1,000,000.00
    Hence I noticed the fictional change in decinal places.
    Should have caught it sooner.
    Regards,
    Sameer

Maybe you are looking for

  • Error involving Report Generation Toolkit and Labview Run Time Engine

    Developed an application using LabVIEW 6.1 and LabVIEW Report Generation Toolkit for Microsoft Office 1.0.1. From there, tried to build a shared application for use with the LabVIEW Run Time Engine. The Run Time version functions properly until "New

  • Urgent - How to join multiple facts and dimensions in OBIEE rpd??

    Hi, In my RPD I have 3 facts and 4 dimensions and the joins defined are as below Physical layer - All joins are FK and inner (1:N) FACTA-------------- DIM_TIME, DIM_CUST,DIM_CAL FACTB-------------- DIM_TIME, DIM_CUST,DIM_CAL FACTC-------------- DIM_T

  • Mac Mini data restore?

    My Mac Mini would not boot apple care said they could replace drive but I should use firewire to use my imac and boot mac mini into slave mode and copy files off.  I did that they replaced the drive how do I get data back? The copy was just drag drop

  • Multiple DTP's in single process chain

    Hello BW guru's can we have many DTP's in a single process chain? If so, how can we do that?

  • Jump directly to the previous record

    Hi Everyone, i am using oracle 9i and i have 20,000 records in my table and i have to do some manual changes in my address column. in the meanwhile i sort my data with respect to anyother column, after sort operation, i want to go back to that specif