Postgres SQL, as run
select to_char(date_trunc('month', billing_period_start), 'YYYY-MM') as billing_month,
service_name,
sum(effective_cost) as total_effective_cost
from focus.cost_and_usage
where tags->>'application' = $1::text
and charge_period_start >= $2::timestamptz
and charge_period_end < $3::timestamptz
group by 1, 2
order by billing_month, total_effective_cost desc nulls last, service_name
limit 500Parameters: $1 = application, $2 = period_start, $3 = period_end
Original FOCUS SQL
SELECT
MONTH(BillingPeriodStart),
ServiceName,
SUM(EffectiveCost) AS TotalEffectiveCost
FROM focus_data_table
WHERE Tags["Application"] = ?
AND ChargePeriodStart >= ? AND ChargePeriodEnd < ?
GROUP BY
MONTH(BillingPeriodStart),
ServiceName