|
1 | 1 | ---
|
2 |
| -title: TRUNC in Azure Cosmos DB query language |
3 |
| -description: Learn about SQL system function TRUNC in Azure Cosmos DB. |
4 |
| -author: ginamr |
| 2 | +title: TRUNC |
| 3 | +titleSuffix: Azure Cosmos DB for NoSQL |
| 4 | +description: An Azure Cosmos DB for NoSQL system function that returns a truncated numeric value. |
| 5 | +author: jcodella |
| 6 | +ms.author: jacodel |
| 7 | +ms.reviewer: sidandrews |
5 | 8 | ms.service: cosmos-db
|
6 | 9 | ms.subservice: nosql
|
7 |
| -ms.topic: conceptual |
8 |
| -ms.date: 06/22/2021 |
9 |
| -ms.author: girobins |
10 |
| -ms.custom: query-reference, ignite-2022 |
| 10 | +ms.topic: reference |
| 11 | +ms.date: 07/24/2023 |
| 12 | +ms.custom: query-reference |
11 | 13 | ---
|
12 |
| -# TRUNC (Azure Cosmos DB) |
| 14 | + |
| 15 | +# TRUNC (NoSQL query) |
| 16 | + |
13 | 17 | [!INCLUDE[NoSQL](../../includes/appliesto-nosql.md)]
|
14 | 18 |
|
15 |
| - Returns a numeric value, truncated to the closest integer value. |
16 |
| - |
| 19 | +Returns a numeric value truncated to the closest integer value. |
| 20 | + |
17 | 21 | ## Syntax
|
18 |
| - |
| 22 | + |
19 | 23 | ```sql
|
20 |
| -TRUNC(<numeric_expr>) |
21 |
| -``` |
22 |
| - |
| 24 | +TRUNC(<numeric_expr>) |
| 25 | +``` |
| 26 | + |
23 | 27 | ## Arguments
|
24 |
| - |
25 |
| -*numeric_expr* |
26 |
| - Is a numeric expression. |
27 |
| - |
| 28 | + |
| 29 | +| | Description | |
| 30 | +| --- | --- | |
| 31 | +| **`numeric_expr`** | A numeric expression. | |
| 32 | + |
28 | 33 | ## Return types
|
29 |
| - |
30 |
| - Returns a numeric expression. |
31 |
| - |
| 34 | + |
| 35 | +Returns a numeric expression. |
| 36 | + |
32 | 37 | ## Examples
|
33 |
| - |
34 |
| - The following example truncates the following positive and negative numbers to the nearest integer value. |
35 |
| - |
36 |
| -```sql |
37 |
| -SELECT TRUNC(2.4) AS t1, TRUNC(2.6) AS t2, TRUNC(2.5) AS t3, TRUNC(-2.4) AS t4, TRUNC(-2.6) AS t5 |
38 |
| -``` |
39 |
| - |
40 |
| - Here is the result set. |
41 |
| - |
42 |
| -```json |
43 |
| -[{t1: 2, t2: 2, t3: 2, t4: -2, t5: -2}] |
44 |
| -``` |
| 38 | + |
| 39 | +This example illustrates various ways to truncate a number to the closest integer. |
| 40 | + |
| 41 | +:::code language="sql" source="~/cosmos-db-nosql-query-samples/scripts/trunc/query.sql" highlight="2-6"::: |
| 42 | + |
| 43 | +:::code language="json" source="~/cosmos-db-nosql-query-samples/scripts/trunc/result.json"::: |
45 | 44 |
|
46 | 45 | ## Remarks
|
47 | 46 |
|
48 |
| -This system function will benefit from a [range index](../../index-policy.md#includeexclude-strategy). |
| 47 | +- This unction benefits from a [range index](../../index-policy.md#includeexclude-strategy). |
49 | 48 |
|
50 | 49 | ## Next steps
|
51 | 50 |
|
52 | 51 | - [System functions Azure Cosmos DB](system-functions.yml)
|
53 |
| -- [Introduction to Azure Cosmos DB](../../introduction.md) |
| 52 | +- [`TRIM`](trim.md) |
0 commit comments