

如需與 Amazon Timestream for LiveAnalytics 類似的功能，請考慮使用 Amazon Timestream for InfluxDB。它提供簡化的資料擷取和單一位數毫秒查詢回應時間，以進行即時分析。[在這裡](https://docs.aws.amazon.com//timestream/latest/developerguide/timestream-for-influxdb.html)進一步了解。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 整合函數
<a name="timeseries-specific-constructs.functions.integrals"></a>

您可以使用積分來尋找時間序列事件每單位時間曲線下的區域。例如，假設您正在追蹤應用程式每單位時間收到的請求量。在此案例中，您可以使用整合函數來判斷在特定期間內，每個指定間隔所處理的請求總量。

Amazon Timestream 支援整合函數的一個變體。本節提供 Timestream for LiveAnalytics 整合函數的使用資訊，以及範例查詢。



## 用量資訊
<a name="w2aab7c59c13c13c15b9"></a>


| 函式 | 輸出資料類型 | Description | 
| --- | --- | --- | 
|  `integral_trapezoidal(timeseries(double))` `integral_trapezoidal(timeseries(double), interval day to second)` `integral_trapezoidal(timeseries(bigint))` `integral_trapezoidal(timeseries(bigint), interval day to second)` `integral_trapezoidal(timeseries(integer), interval day to second)` `integral_trapezoidal(timeseries(integer))`  |  double  |  使用[梯形規則](https://wikipedia.org/wiki/Trapezoidal_rule)，根據`interval day to second`針對`timeseries`所提供 指定的 近似[積分](https://wikipedia.org/wiki/Integral)。間隔天數到第二個參數為選用，預設值為 `1s`。如需間隔的詳細資訊，請參閱 [間隔和持續時間](date-time-functions.md#date-time-functions-interval-duration)。  | 

## 查詢範例
<a name="w2aab7c59c13c13c15c11"></a>

**Example**  
計算特定主機在過去 1 小時內每 5 分鐘處理的請求總量：  

```
SELECT INTEGRAL_TRAPEZOIDAL(CREATE_TIME_SERIES(time, measure_value::double), 5m) AS result FROM sample.DevOps 
WHERE measure_name = 'request' 
AND hostname = 'host-Hovjv' 
AND time > ago (1h) 
GROUP BY hostname, measure_name
```