Postgres SQL, as run
select date_trunc('month', billing_period_start at time zone 'UTC') as billing_month,
provider_name as provider_name,
service_category as service_category,
service_name as service_name,
charge_category as charge_category,
sum(effective_cost) as total_effective_cost
from focus.cost_and_usage
where billing_period_start >= $1::timestamptz
and billing_period_end < $2::timestamptz
group by 1, provider_name, service_category, service_name, charge_category
order by billing_month, total_effective_cost desc nulls last, provider_name, service_name
limit 500Parameters: $1 = billing_period_start, $2 = billing_period_end
Original FOCUS SQL
SELECT
MONTH(BillingPeriodStart),
ProviderName,
ServiceCategory,
ServiceName,
ChargeCategory,
SUM(EffectiveCost) AS TotalEffectiveCost
FROM focus_data_table
WHERE BillingPeriodStart >= ? AND BillingPeriodEnd < ?
GROUP BY
MONTH(BillingPeriodStart),
ProviderName,
ServiceCategory,
ServiceName,
ChargeCategory