[
https://issues.apache.org/jira/browse/TRAFODION-3129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16535136#comment-16535136
]
Anoop Sharma commented on TRAFODION-3129:
-----------------------------------------
precision and scale of round result depends on the precision/scale of the
operands operand and is determined when the query is compiled.
The value will be correctly rounded by removing the trailing digits and
replacing them by zeroes.
In the example, values are literals but round can also be used on non-literals
where the rounding value is not known at compile time.
In the example below, column 'b' is being used to indicate the rounded digits.
Depending on its contents, different digits will be rounded. It needs to be
known at compile time what the result precision/scale should be so describe on
the query can return precision/scale to the caller, and since it cannot be set
to different values based on the column contents, the result precision/scale is
computed to a value that can handle all possible contents of first and second
operand.
>>create table tround(a numeric(10,6), b int);
--- SQL operation complete.
>>insert into tround values (1234.567890, 2), (1234.567890, 4);
--- 2 row(s) inserted.
>>select round(a,b) from tround;
(EXPR)
---------------------
1234.570000
1234.570000
1234.567900
--- 3 row(s) selected.
>>
Same logic applies when literals or params are used in a query.
The result in the Jira example is expected correct behavior.
> round(m,n) function does not cut the value to n digits precision
> -----------------------------------------------------------------
>
> Key: TRAFODION-3129
> URL: https://issues.apache.org/jira/browse/TRAFODION-3129
> Project: Apache Trafodion
> Issue Type: Bug
> Components: sql-general
> Affects Versions: 2.2.0
> Reporter: Yuan Liu
> Priority: Major
> Fix For: any
>
>
> Below sql should return 123.46, but it returns 123.4600,
> >>select round(123.4567,2) from dual;
> (EXPR)
> ---------------------
> 123.4600
> --- 1 row(s) selected.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)