From 0dad2d622c0ad290a83eaa049a532777ec370570 Mon Sep 17 00:00:00 2001 From: Lucas Bacciotti Date: Mon, 11 Nov 2024 11:26:46 +0000 Subject: [PATCH] Defining a date range on CTE to get the max date from the current month. --- ...porting_awscostentrylineitem_summary_by_ec2_compute_p.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/koku/masu/database/trino_sql/reporting_awscostentrylineitem_summary_by_ec2_compute_p.sql b/koku/masu/database/trino_sql/reporting_awscostentrylineitem_summary_by_ec2_compute_p.sql index cdb89a2f69..04a0811e55 100644 --- a/koku/masu/database/trino_sql/reporting_awscostentrylineitem_summary_by_ec2_compute_p.sql +++ b/koku/masu/database/trino_sql/reporting_awscostentrylineitem_summary_by_ec2_compute_p.sql @@ -54,7 +54,10 @@ cte_latest_values as ( AND product_productfamily LIKE '%Compute Instance%' AND lineitem_resourceid != '' AND lineitem_usagestartdate = ( - SELECT max(date(lv.lineitem_usagestartdate)) as usage_start from hive.{{schema | sqlsafe}}.aws_line_items_daily as lv + SELECT max(date(lv.lineitem_usagestartdate)) AS usage_start + FROM hive.{{schema | sqlsafe}}.aws_line_items_daily AS lv + WHERE year = '{{year | sqlsafe}}' + AND month = '{{month | sqlsafe}}' ) GROUP BY lineitem_resourceid,