SELECT line_item_usage_account_id AS "Account Id",
line_item_legal_entity AS "Legal Entity",
SUM(savings_plan_net_savings_plan_effective_cost) AS "Amount (USD)",
savings_plan_savings_plan_a_r_n AS "Savings Plans Id"
FROM (データベース名).(テーブル名)
WHERE year='2023'
AND month='12'
AND line_item_line_item_type = 'SavingsPlanCoveredUsage'
AND savings_plan_savings_plan_a_r_n = 'arn:aws:savingsplans::(SP購入AWSアカウントID):savingsplan/(Savings Plan ID)'
GROUP BY line_item_usage_account_id,
line_item_legal_entity,
savings_plan_savings_plan_a_r_n