- Source
- FOCUS use-case SQL
- Status
- Not in v1.0 sample
- Results
- Not run
- Mode
- Read-only
- Library snapshot (UTC)
- 2026-10-08
CommitmentProgramEligibilityDetails (FOCUS v1.4) is absent from the v1.0 sample, so eligible program types and eligible cost cannot be derived.
Review the original SQL below and the required columns before using a newer FOCUS dataset.
Original FOCUS SQL
WITH CommitmentDiscountEligible AS (
SELECT
CU.ServiceProviderName,
JSON_VALUE(CP, '$.ProgramType') AS ProgramType,
CU.EffectiveCost,
-- EffectiveCost = BilledCost for uncovered rows; used here for ratio consistency
CASE WHEN CU.CommitmentDiscountId IS NULL THEN CU.EffectiveCost ELSE 0 END AS UncoveredCost
FROM focus_data_table CU
CROSS JOIN
UNNEST(JSON_EXTRACT_ARRAY(CU.CommitmentProgramEligibilityDetails, '$.CommitmentPrograms')) AS CP
WHERE CU.ChargePeriodStart >= ? AND CU.ChargePeriodEnd < ?
AND CU.ChargeCategory = 'Usage'
AND CU.CommitmentProgramEligibilityDetails IS NOT NULL
-- Replace with provider-specific discount-bearing program types
AND JSON_VALUE(CP, '$.ProgramType') IN ('FlexibleSpendPlan', 'ResourceReservation')
)
SELECT
ServiceProviderName,
ProgramType AS EligibleProgramType,
SUM(EffectiveCost) AS EligibleCost,
SUM(UncoveredCost) AS UncoveredEligibleCost,
SUM(UncoveredCost) / NULLIF(SUM(EffectiveCost), 0) AS UncoveredRate
FROM CommitmentDiscountEligible
GROUP BY ServiceProviderName, ProgramType
ORDER BY UncoveredEligibleCost DESC