Tagging is quite common in large organizations, it fulfills the requirement of allocating costs back to specific business units. It is also important for optimizing workload allocation and for measuring performance.
SELECT "bill_payer_account_id",
"product_product_name",
"line_item_usage_type",
"line_item_line_item_description",
resource_tags_user_cost_center,
round(sum(line_item_unblended_cost), 2) as cost
FROM "costmaster"."monthly_report"
WHERE length("resource_tags_user_cost_center") > 0
GROUP BY "resource_tags_user_cost_center",
"bill_payer_account_id",
"product_product_name",
"line_item_usage_type",
"line_item_line_item_description"
ORDER BY cost desc
LIMIT 20
SELECT "bill_payer_account_id",
"product_product_name",
"line_item_usage_type",
"line_item_line_item_description",
round(sum(line_item_unblended_cost), 2) as cost
FROM "costmaster"."monthly_report"
WHERE length("resource_tags_user_cost_center") = 0
GROUP BY "bill_payer_account_id",
"product_product_name",
"line_item_usage_type",
"line_item_line_item_description"
ORDER BY cost desc
LIMIT 20