[
https://issues.apache.org/jira/browse/TRAFODION-3306?focusedWorklogId=233214&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-233214
]
ASF GitHub Bot logged work on TRAFODION-3306:
---------------------------------------------
Author: ASF GitHub Bot
Created on: 26/Apr/19 00:57
Start Date: 26/Apr/19 00:57
Worklog Time Spent: 10m
Work Description: DaveBirdsall commented on pull request #1837:
[TRAFODION-3306] Add the TRUNC Function in the Trafodion SQL Reference Manual
URL: https://github.com/apache/trafodion/pull/1837#discussion_r278779643
##########
File path:
docs/sql_reference/src/asciidoc/_chapters/sql_functions_and_expressions.adoc
##########
@@ -12460,6 +12460,122 @@ CHAR(20). This expression uses the TRIM function to
return the value
TRIM(first_name) || ' ' || TRIM (last_name)
```
+[[trunc_function]]
+== TRUNC Function
+
+The TRUNC (TRUNCATE) function truncates `_numeric-expression_` on an optional
`_decimal-place_` decimal position(s), that is, it rounds down
`_numeric-expression_` to the nearest (or equal) integer closer to zero
*without rounding*.
Review comment:
The second argument makes this description awkward. If the second argument
were zero, then we are rounding down to the nearest integer closer to zero. If
the second argument is positive. we aren't necessarily rounding to an integer.
TRUNC(1.23,1) gives 1.2, and 1.2 isn't an integer. And I'm not sure what
happens when the second argument is negative. Maybe TRUNC(123,-1) gives 120?
If this is true, one way to describe this is TRUNC is like ROUND, except it
always rounds toward zero.
Here is a possible wordsmith (please do a bit of experimentation to see if
this is right);
The TRUNC (TRUNCATE) function truncates '_numeric-expression_'. If the
second argument is not supplied, or is supplied and is zero, this rounds the
'_numeric-expression_' to the nearest integer closer to zero. If the second
argument is supplied and is positive, say, n, it rounds the
'_numeric_expression_' to the nearest multiple of 10^-n that is closer to zero.
In these two cases, decimal places to the right of the decimal point are
effectively deleted. If the second argument is supplied and is negative, say,
-n, it rounds '_numeric_expression_' to the nearest multiple of 10^n. Any
decimal places to the right of the decimal point are effectively deleted.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 233214)
Time Spent: 40m (was: 0.5h)
> Add the TRUNC Function in the Trafodion SQL Reference Manual
> ------------------------------------------------------------
>
> Key: TRAFODION-3306
> URL: https://issues.apache.org/jira/browse/TRAFODION-3306
> Project: Apache Trafodion
> Issue Type: Documentation
> Reporter: Liu Yu
> Priority: Major
> Fix For: 2.4
>
> Time Spent: 40m
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)