プライマリ・コンテンツに移動
Oracle® Big Data Discovery Cloud Service EQLリファレンス

E65371-04
目次へ
目次
索引へ移動
索引

前
次
機械翻訳について

先月から前月までの変化率を計算しています

次の例では、現在のフィルタに一致するデータの最新の月を検索し、その月を前の月と、現在のフィルタに一致するデータと再度比較します。

/* This computes the percent change between the most
  * recent month in the current nav state, compared to the prior
  * month in the nav state. Note that, if there's only
  * one month represented in the nav state, this will return NULL.
  */
DEFINE Input AS 
SELECT
   ARB(DimDate_CalendarYear) AS CalYear,
   ARB(DimDate_MonthNumberOfYear) AS NumMonth,
   DimDate_CalendarYear * 12 + DimDate_MonthNumberOfYear AS OrdinalMonth,
   SUM(FactSales_SalesAmount) AS TotalSales 
FROM SaleState
GROUP BY OrdinalMonth;

RETURN Result AS 
SELECT
   CalYear AS CalYear,
   NumMonth AS NumMonth,
   TotalSales AS TotalSales,
   Input[OrdinalMonth - 1].TotalSales AS PriorMonthSales,
   100 * (TotalSales - PriorMonthSales) / PriorMonthSales AS PercentChange 
FROM Input 
ORDER BY CalYear DESC, NumMonth DESC 
PAGE(0, 1)