Postgres SQL, as run
select billing_period_start,
commitment_discount_id,
coalesce(commitment_discount_name, regexp_replace(commitment_discount_id, '^.*/', '')) as commitment_label,
commitment_discount_name,
commitment_discount_type,
charge_frequency,
sum(billed_cost) as total_billed_cost
from focus.cost_and_usage
where billing_period_start >= $1::timestamptz
and billing_period_start < $2::timestamptz
and charge_frequency = 'Recurring'
and commitment_discount_id is not null
group by 1, 2, 3, 4, 5, 6
order by billing_period_start, total_billed_cost desc nulls last, commitment_discount_id
limit 500Parameters: $1 = billing_period_start, $2 = billing_period_start_before
Original FOCUS SQL
SELECT
BillingPeriodStart,
CommitmentDiscountId,
CommitmentDiscountName,
CommitmentDiscountType,
ChargeFrequency,
SUM(BilledCost) AS TotalBilledCost
FROM focus_data_table
WHERE BillingPeriodStart >= ? AND BillingPeriodStart < ?
AND ChargeFrequency = 'Recurring'
AND CommitmentDiscountId IS NOT NULL
GROUP BY
BillingPeriodStart,
CommitmentDiscountId,
CommitmentDiscountName,
CommitmentDiscountType,
ChargeFrequency