| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information for Amazon Athena. The output will include detailed information about the resource id. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_usage_type, | |
| line_item_resource_id, | |
| product_region, | |
| line_item_product_code, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonAthena' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_usage_start_date, | |
| line_item_usage_type, | |
| line_item_resource_id, | |
| product_region, | |
| line_item_product_code | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC | |
| LIMIT 20; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information per linked account for AWS Glue. The output will include detailed information about the resource id (Glue Crawler) and API operation. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_operation, | |
| CASE | |
| WHEN LOWER(line_item_operation) = 'jobrun' THEN SPLIT_PART(line_item_resource_id, 'job/', 2) | |
| WHEN LOWER(line_item_operation) = 'crawlerrun' THEN SPLIT_PART(line_item_resource_id, 'crawler/', 2) | |
| ELSE 'N/A' | |
| END AS case_line_item_resource_id, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16, 8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = ('AWS Glue') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_operation, | |
| line_item_resource_id | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information per linked account for each Kinesis product (Amazon Kinesis, Amazon Kinesis Firehose, and Amazon Kinesis Analytics). The output will include detailed information about the resource id (Stream, Delivery Stream, etc…) and API operation. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id,':',6) AS split_line_item_resource_id, | |
| product_product_name, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16, 8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_Name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code LIKE '%Kinesis%' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_resource_id, | |
| product_product_name | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and amortized cost as well as usage information per linked account for Amazon Elasticsearch. The output will include detailed information about the resource id (ES Domain), usage type, and API operation. The usage amount and cost will be summed and the cost will be in descending order. This query includes RI and SP true up which will show any upfront fees to the account that purchased the pricing model.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id,':',6) AS split_line_item_resource_id, | |
| product_product_family, | |
| product_instance_family, | |
| product_instance_type, | |
| pricing_term, | |
| product_storage_media, | |
| product_transfer_type, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN line_item_usage_amount | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN line_item_usage_amount | |
| WHEN (line_item_line_item_type = 'Usage') THEN line_item_usage_amount | |
| ELSE 0 | |
| END) AS sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (-savings_plan_amortized_upfront_commitment_for_billing_period) | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (-reservation_amortized_upfront_fee_for_billing_period) | |
| ELSE 0 | |
| END) AS sum_ri_sp_trueup, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN line_item_unblended_cost | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS sum_ri_sp_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name in ('Amazon Elasticsearch Service' ,'Amazon OpenSearch Service') | |
| AND line_item_product_code = 'AmazonES' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| SPLIT_PART(line_item_resource_id,':',6), | |
| product_product_family, | |
| product_instance_family, | |
| product_instance_type, | |
| pricing_term, | |
| product_storage_media, | |
| product_transfer_type | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| product_product_family, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per linked account for Amazon EMR. The cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_usage_type ,':',2) AS split_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Elastic MapReduce' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| line_item_line_item_type | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost DESC, | |
| split_line_item_usage_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and usage information per linked account for Amazon QuickSight. The output will include detailed information about the usage type and its usage amount. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| CASE | |
| WHEN LOWER(line_item_usage_type) LIKE 'qs-user-enterprise%' THEN 'Users - Enterprise' | |
| WHEN LOWER(line_item_usage_type) LIKE 'qs-user-standard%' THEN 'Users - Standard' | |
| WHEN LOWER(line_item_usage_type) LIKE 'qs-reader%' THEN 'Reader Usage' | |
| WHEN LOWER(line_item_usage_type) LIKE '%spice' THEN 'SPICE' | |
| WHEN LOWER(line_item_usage_type) LIKE '%alerts%' THEN 'Alerts' | |
| ELSE line_item_usage_type | |
| END AS case_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon QuickSight' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| 4 -- refers to case_line_item_usage_type | |
| ORDER BY | |
| month_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and usage information per linked account for all types of Amazon MSK, including OD and Serverless. The output will include detailed information about the usage type and its usage amount. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_product_code, | |
| line_item_line_item_description, | |
| line_item_operation, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonMSK' | |
| AND line_item_line_item_type NOT IN ('Tax','Refund','Credit') | |
| GROUP BY 1,2,3,4,5 | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and amortized cost as well as usage information per linked account for Amazon MQ. The output will include detailed information about the resource id (broker), usage type, and API operation. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| product_broker_engine, | |
| line_item_usage_type, | |
| product_product_family, | |
| pricing_unit, | |
| pricing_term, | |
| SPLIT_PART(line_item_usage_type, ':', 2) AS split_line_item_usage_type, | |
| SPLIT_PART(line_item_resource_id, ':', 7) AS split_line_item_resource_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_operation, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon MQ' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| product_broker_engine, | |
| product_product_family, | |
| pricing_unit, | |
| pricing_term, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| line_item_resource_id, | |
| line_item_operation | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC, | |
| split_line_item_usage_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information per linked account for Amazon SES. The output will include detailed information about the product family (Sending Attachments, Data Transfer, etc…) and usage type. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_product_family, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%%DataTransfer-In-Bytes%%' THEN 'Data Transfer GB (IN) ' | |
| WHEN line_item_usage_type LIKE '%%DataTransfer-Out-Bytes%%' THEN 'Data Transfer GB (Out)' | |
| WHEN line_item_usage_type LIKE '%%AttachmentsSize-Bytes%%' THEN 'Attachments GB' | |
| WHEN line_item_usage_type LIKE '%%Recipients' THEN 'Recipients' | |
| WHEN line_item_usage_type LIKE '%%Recipients-EC2' THEN 'Recipients' | |
| WHEN line_item_usage_type LIKE '%%Recipients-MailboxSim' THEN 'Recipients (MailboxSimulator)' | |
| WHEN line_item_usage_type LIKE '%%Message%%' THEN 'Messages' | |
| WHEN line_item_usage_type LIKE '%%ReceivedChunk%%' THEN 'Received Chunk' | |
| ELSE 'Others' | |
| END AS case_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_Name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Simple Email Service' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_product_family, | |
| 5 --refers to case_line_item_usage_type | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per linked account for Amazon SNS. The output will include detailed information about the product family, API Operation, and usage type. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| CONCAT(product_product_family,' - ',line_item_operation) AS concat_product_product_family, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_Name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Simple Notification Service' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| CONCAT(product_product_family,' - ',line_item_operation) | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide the top 20 daily unblended costs as well as usage information for a specified linked account for Amazon SQS. The output will include detailed information about the resource id (queue), usage type, and API operation. The cost will be summed and in descending order. This is helpful for tracking down spikes in cost for SQS usage. Cost Explorer will provide you all of this information except the resource ID. This allows your investigation to be targeted to a time range, linked account, API operation, and resource that is generating the usage.? | |
| COMPLETION: SELECT | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_usage_type, | |
| line_item_operation, | |
| line_item_resource_id, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_Name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AWSQueueService' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| line_item_operation, | |
| line_item_resource_id | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC | |
| LIMIT 20; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information for Amazon SQS, grouped by account and operation. The operation is also grouped using product_product_family, which results in values such as “Data Transfer - Receive” and “API Request - SendMessageBatch”. Output is ordered by date, then by cost (descending). This can be used to identify specific API operations driving the most daily cost, which allows for targeted investigation into optimization opportunities.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| CONCAT(product_product_family,' - ',line_item_operation) AS concat_product_product_family, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter}} | |
| AND line_item_product_code = 'AWSQueueService' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| CONCAT(product_product_family,' - ',line_item_operation) | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides AWS Marketplace subscription costs including subscription product name, associated linked account, and monthly total unblended cost. This query includes tax, however this can be filtered out in the WHERE clause. Please refer to the CUR Query Library Helpers section for assistance. CUR Query Library Helpers section? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| CASE line_item_usage_start_date | |
| WHEN NULL THEN DATE_FORMAT(DATE_PARSE(CONCAT(SPLIT_PART('${table_name}','_',5),'01'),'%Y%m%d'),'%Y-%m-01') | |
| ELSE DATE_FORMAT(line_item_usage_start_date,'%Y-%m-01') | |
| END AS case_line_item_usage_start_time, | |
| bill_billing_entity, | |
| product_product_name, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND bill_billing_entity = 'AWS Marketplace' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| 3, --refers to case_line_item_usage_start_time, | |
| bill_billing_entity, | |
| product_product_name | |
| ORDER BY | |
| case_line_item_usage_start_time ASC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides a list of refunds and credits issued. Output is grouped by payer, linked account, month, line item type, service, and line item description. This allows for analysis of refunds and credits along any of these grouped dimensions. For example, “what refunds or credits were issued to account 111122223333 for service ABC in January 2022?” or “what was the total refund issued across all accounts for payer 444455556666 with line item description XYZ?”? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_TRUNC('month',line_item_usage_start_date) as month_line_item_usage_start_date, | |
| line_item_line_item_type, | |
| CASE | |
| WHEN (bill_billing_entity = 'AWS Marketplace' AND line_item_line_item_type NOT LIKE '%Discount%') THEN product_product_name | |
| WHEN (product_servicecode = '') THEN line_item_product_code | |
| ELSE product_servicecode | |
| END case_service, | |
| line_item_line_item_description, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_unblended_cost < 0 | |
| AND line_item_line_item_type <> 'SavingsPlanNegation' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_TRUNC('month',line_item_usage_start_date), | |
| line_item_line_item_type, | |
| 5, --refers to case_service | |
| line_item_line_item_description | |
| ORDER BY | |
| month_line_item_usage_start_date ASC, | |
| sum_line_item_unblended_cost ASC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides an aggregated report of savings from purchased reservations across multiple services - EC2, Elasticache, OpenSearch (formerly Amazon ElasticSearch), and RDS. This is similar to what can be found in Cost Explorer Reservation Utilization reports, except aggregated across all services offering reservations, allowing for easier organizational reporting on total savings. Output can be used to identify savings per specific reservation ARN, as well as savings per service, savings per linked account, savings per region, and savings per specific instance/node type.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| line_item_product_code, | |
| reservation_reservation_a_r_n, | |
| SPLIT_PART(line_item_usage_type,':', 2) AS split_line_item_usage_type, | |
| SPLIT_PART(reservation_reservation_a_r_n,':', 4) AS split_product_region, -- split ARN for region due to product_region inconsistencies | |
| SUM(CAST(pricing_public_on_demand_cost AS DECIMAL (16,8))) AS sum_pricing_public_on_demand_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| END) AS sum_case_reservation_effective_cost, | |
| SUM(TRY_CAST(pricing_public_on_demand_cost AS DECIMAL(16, 8))) | |
| - SUM(CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| END) AS sum_case_reservation_net_savings | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code IN ('AmazonEC2','AmazonRedshift','AmazonRDS','AmazonES','AmazonElastiCache') | |
| AND line_item_line_item_type IN ('Fee','RIFee','DiscountedUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| line_item_product_code, | |
| reservation_reservation_a_r_n, | |
| SPLIT_PART(line_item_usage_type,':', 2), | |
| SPLIT_PART(reservation_reservation_a_r_n,':', 4) | |
| ORDER BY | |
| month_line_item_usage_start_date, | |
| line_item_product_code, | |
| split_line_item_usage_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides all rewarded Migration Acceleration Program (MAP) credits grouped by month, year, product credit source and account id. Default is for all time. A line is included as an example if a date filter is desired. Please refer to the CUR Query Library Helpers section for assistance. Migration Acceleration Program CUR Query Library Helpers section? | |
| COMPLETION: select | |
| month, | |
| year, | |
| line_item_line_item_type, | |
| line_item_line_item_description, | |
| line_item_usage_account_id, | |
| sum(line_item_unblended_cost) sum_line_item_unblended_cost | |
| from ${tableName} | |
| where | |
| line_item_line_item_type in ('Refund','Credit') and | |
| line_item_line_item_description like '%_MPE%' | |
| -- default is all MAP credits for the entire account for all time, add next line to filter | |
| -- and ${date_filter} | |
| group by 1,2,3,4,5; | |
| PROMPT: What SQL query corresponds to the following purpose: This query pulls all ACTIVE Reserved Instance ARNs for Amazon EC2 and produces their utilization for last month. This query will give you a very granular look at which Reserved Instance purchases were not being utilized to their full extent last month. This query is written for Amazon EC2, however, commenting the line_item_product_code line in the WHERE clause will output all Reserved Instances.? | |
| COMPLETION: -- EC2 Reservations active in current month ordered by expiration first | |
| SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m') AS month_line_item_usage_start_date, | |
| bill_bill_type, | |
| line_item_product_code, | |
| line_item_usage_type, | |
| product_region, | |
| reservation_subscription_id, | |
| reservation_reservation_a_r_n, | |
| pricing_purchase_option, | |
| pricing_offering_class, | |
| pricing_lease_contract_length, | |
| reservation_number_of_reservations, | |
| reservation_start_time, | |
| reservation_end_time, | |
| reservation_modification_status, | |
| reservation_total_reserved_units, | |
| reservation_unused_quantity, | |
| TRY_CAST(1 - (TRY_CAST(reservation_unused_quantity AS Decimal(16,8)) / TRY_CAST(reservation_total_reserved_units AS Decimal(16,8))) as Decimal(16,8)) AS calc_percentage_utilized | |
| FROM | |
| ${table_name} | |
| WHERE | |
| CAST("concat"("year", '-', "month", '-01') AS date) = "date_trunc"('month', current_date) - INTERVAL '1' MONTH --last month | |
| AND pricing_term = 'Reserved' | |
| AND line_item_line_item_type IN ('Fee','RIFee') | |
| AND line_item_product_code = 'AmazonEC2' --EC2 only, comment out for all reservation types | |
| AND bill_bill_type = 'Anniversary' --identify | |
| AND try_cast(date_parse(SPLIT_PART(reservation_end_time, 'T', 1), '%Y-%m-%d') as date) > cast(current_date as date) --res exp time after today's date | |
| GROUP BY | |
| bill_bill_type, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| reservation_reservation_a_r_n, | |
| reservation_subscription_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m'), | |
| line_item_product_code, | |
| line_item_usage_type, | |
| product_region, | |
| pricing_purchase_option, | |
| pricing_offering_class, | |
| pricing_lease_contract_length, | |
| reservation_number_of_reservations, | |
| reservation_start_time, | |
| reservation_end_time, | |
| reservation_modification_status, | |
| reservation_total_reserved_units, | |
| reservation_unused_quantity | |
| ORDER BY | |
| reservation_unused_quantity DESC, | |
| reservation_end_time ASC, | |
| calc_percentage_utilized ASC | |
| PROMPT: What SQL query corresponds to the following purpose: This query pulls all ACTIVE Savings Plan ARNs and produces their utilization for last month. This query will give you a very granular look at which Savings Plan purchases were not being utilized to their full extent last month.? | |
| COMPLETION: SELECT | |
| SPLIT_PART(savings_plan_savings_plan_a_r_n, '/', 2) AS split_savings_plan_savings_plan_a_r_n, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m') AS month_line_item_usage_start_date, | |
| savings_plan_offering_type, | |
| savings_plan_region, | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_start_time),'%Y-%m-%d') AS day_savings_plan_start_time, | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_end_time),'%Y-%m-%d') AS day_savings_plan_end_time, | |
| savings_plan_payment_option, | |
| savings_plan_purchase_term, | |
| SUM(TRY_CAST(savings_plan_recurring_commitment_for_billing_period AS DECIMAL(16, 8))) AS sum_savings_plan_recurring_committment_for_billing_period, | |
| SUM(TRY_CAST(savings_plan_total_commitment_to_date AS DECIMAL(16, 8))) AS sum_savings_plan_total_commitment_to_date, | |
| SUM(TRY_CAST(savings_plan_used_commitment AS DECIMAL(16, 8))) AS sum_savings_plan_used_commitment, | |
| AVG(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanRecurringFee' THEN TRY_CAST(savings_plan_total_commitment_to_date AS DECIMAL(8, 2)) | |
| END) AS "Hourly Commitment", | |
| -- (used commitment / total commitment) * 100 = utilization % | |
| TRY_CAST(((SUM(TRY_CAST(savings_plan_used_commitment AS DECIMAL(16, 8))) / SUM(TRY_CAST(savings_plan_total_commitment_to_date AS DECIMAL(16, 8))))) AS DECIMAL(16, 8)) AS calc_savings_plan_utilization_percent | |
| FROM | |
| ${table_name} | |
| WHERE | |
| CAST("concat"("year", '-', "month", '-01') AS date) = "date_trunc"('month', current_date) - INTERVAL '1' MONTH --last month | |
| AND savings_plan_savings_plan_a_r_n <> '' | |
| AND line_item_line_item_type = 'SavingsPlanRecurringFee' | |
| AND try_cast(date_parse(SPLIT_PART(savings_plan_end_time, 'T', 1), '%Y-%m-%d') as date) > cast(current_date as date) --res exp time after today's date | |
| GROUP BY | |
| SPLIT_PART(savings_plan_savings_plan_a_r_n, '/', 2), | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m'), | |
| savings_plan_offering_type, | |
| savings_plan_region, | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_start_time),'%Y-%m-%d'), | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_end_time),'%Y-%m-%d'), | |
| savings_plan_payment_option, | |
| savings_plan_purchase_term | |
| ORDER BY | |
| calc_savings_plan_utilization_percent DESC, | |
| day_savings_plan_end_time, | |
| split_savings_plan_savings_plan_a_r_n, | |
| month_line_item_usage_start_date; | |
| PROMPT: What SQL query corresponds to the following purpose: This query produces the top 50 moving resources by 1/ cost delta and 2/ change in percentage. The parameters have been adjusted for comparison of resources from three days prior and two days prior as CUR may take up to 48 hours to update all estimated charges. Additionally, this query only pulls resources with greater than $5 in unblended cost in order to reduce noise from resources which did not exist in one of the look back periods or spun up at the end of one of the look back periods. These parameters may be adjusted as needed.? | |
| COMPLETION: SELECT | |
| a.line_item_usage_account_id AS "line_item_usage_account_id", | |
| old_line_item_resource_id, | |
| old_line_item_unblended_cost AS "cost_three_days_prior", | |
| new_line_item_unblended_cost AS "cost_two_days_prior", | |
| (new_line_item_unblended_cost - old_line_item_unblended_cost) AS "cost_delta", | |
| (((new_line_item_unblended_cost - old_line_item_unblended_cost)/old_line_item_unblended_cost)*100) AS "change_percentage", | |
| a.usage_date AS "date_three_days_prior", | |
| b.usage_date AS "date_two_days_prior", | |
| a.product_product_name AS "product_product_name" | |
| FROM | |
| ( | |
| ( | |
| SELECT | |
| distinct "line_item_resource_id" as old_line_item_resource_id, | |
| line_item_usage_account_id, | |
| product_product_name, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') usage_date, | |
| sum(line_item_unblended_cost) as old_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| "line_item_resource_id" <> '' | |
| AND line_item_unblended_cost > 5 | |
| AND "line_item_usage_start_date" = current_date - INTERVAL '3' DAY | |
| GROUP BY | |
| 1, -- resource id three days prior | |
| 2, -- account id | |
| 3, -- product name | |
| 4 -- usage date | |
| ) a | |
| FULL OUTER JOIN | |
| ( | |
| SELECT | |
| distinct "line_item_resource_id" as new_line_item_resource_id, | |
| line_item_usage_account_id, | |
| product_product_name, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') usage_date, | |
| SUM(line_item_unblended_cost) as new_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| "line_item_resource_id" <> '' | |
| AND line_item_unblended_cost > 5 | |
| AND "line_item_usage_start_date" = current_date - INTERVAL '2' DAY | |
| GROUP BY | |
| 1, -- resource id two days prior | |
| 2, -- account id | |
| 3, -- product name | |
| 4 -- usage date | |
| ) b ON a.old_line_item_resource_id = b.new_line_item_resource_id | |
| ) | |
| ORDER BY | |
| 5 DESC, -- cost delta | |
| 6 DESC -- change percentage | |
| LIMIT 50 | |
| PROMPT: What SQL query corresponds to the following purpose: This query will display the top costs for all spend with the product code of ‘AmazonEC2’. This will include all pricing categories (i.e. OnDemand, Reserved etc..) as well as charges for storage on EC2 (i.e. gp2). The query will output the product code as well as the product description to provide context. It is ordered by largest to smallest spend.? | |
| COMPLETION: SELECT | |
| line_item_product_code, | |
| line_item_line_item_description, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonEC2' | |
| AND line_item_line_item_type NOT IN ('Tax','Refund','Credit') | |
| GROUP BY | |
| line_item_product_code, | |
| line_item_line_item_description | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide the EC2 usage quantity measured in hours for each purchase option and each instance type. The output will include detailed information about the instance type, amortized cost, purchase option, and usage quantity. The output will be ordered by usage quantity in descending order. This query will not run against CUR data from accounts which have purchased EC2 Reserved Instances or Savings Plans. This query will not run against CUR data from accounts which have purchased EC2 Reserved Instances or Savings Plans. not Pricing Page Please refer to the EC2 pricing page. EC2 pricing page? | |
| COMPLETION: SELECT | |
| bill_billing_period_start_date, | |
| line_item_usage_start_date, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| CASE | |
| WHEN (line_item_usage_type LIKE '%SpotUsage%') THEN SPLIT_PART(line_item_usage_type, ':', 2) | |
| ELSE product_instance_type | |
| END AS case_product_instance_type, | |
| CASE | |
| WHEN (savings_plan_savings_plan_a_r_n <> '') THEN 'SavingsPlan' | |
| WHEN (reservation_reservation_a_r_n <> '') THEN 'Reserved' | |
| WHEN (line_item_usage_type LIKE '%Spot%') THEN 'Spot' | |
| ELSE 'OnDemand' | |
| END AS case_purchase_option, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_savings_plan_effective_cost | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'Usage' THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS sum_amortized_cost, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND (line_item_product_code = 'AmazonEC2' | |
| AND product_servicecode <> 'AWSDataTransfer' | |
| AND line_item_operation LIKE '%RunInstances%' | |
| AND line_item_usage_type NOT LIKE '%DataXfer%' | |
| ) | |
| AND (line_item_line_item_type = 'Usage' | |
| OR (line_item_line_item_type = 'SavingsPlanCoveredUsage') | |
| OR (line_item_line_item_type = 'DiscountedUsage') | |
| ) | |
| -- excludes consumed ODCR hours from total | |
| AND product_capacitystatus != 'AllocatedCapacityReservation' | |
| GROUP BY | |
| bill_billing_period_start_date, | |
| line_item_usage_start_date, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| 5, --refers to case_product_instance_type | |
| 6 --refers to case_purchase_option | |
| ORDER BY | |
| sum_line_item_usage_amount DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide EC2 consumption of Savings Plans across Compute resources by linked accounts. It also provides you with the savings received from these Savings Plans and which Savings Plans its connected to. The output is ordered by date.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(savings_plan_savings_plan_a_r_n, '/', 2) AS savings_plan_savings_plan_a_r_n, | |
| savings_plan_offering_type, | |
| savings_plan_region, | |
| CASE | |
| WHEN line_item_product_code = 'AmazonECS' THEN 'Fargate' | |
| WHEN line_item_product_code = 'AWSLambda' THEN 'Lambda' | |
| ELSE product_instance_type_family | |
| END AS case_instance_type_family, | |
| savings_plan_end_time, | |
| SUM(TRY_CAST(line_item_unblended_cost AS DECIMAL(16, 8))) AS sum_line_item_unblended_cost, | |
| SUM(TRY_CAST(savings_plan_savings_plan_effective_cost AS DECIMAL(16, 8))) AS sum_savings_plan_savings_plan_effective_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND savings_plan_savings_plan_a_r_n <> '' | |
| AND line_item_line_item_type = 'SavingsPlanCoveredUsage' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| SPLIT_PART(savings_plan_savings_plan_a_r_n, '/', 2), | |
| savings_plan_offering_type, | |
| savings_plan_region, | |
| 7, -- refers to case_instance_type_family | |
| savings_plan_end_time | |
| ORDER BY | |
| day_line_item_usage_start_date; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide details about Compute usage that is covered by Savings Plans. The output will include detailed information about the usage type, usage amount, Savings Plans ARN, line item description, and Savings Plans effective savings as compared to On-Demand pricing. The public pricing on-demand cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| bill_billing_period_start_date, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| savings_plan_savings_plan_a_r_n, | |
| line_item_product_code, | |
| line_item_usage_type, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount, | |
| line_item_line_item_description, | |
| pricing_public_on_demand_rate, | |
| SUM(pricing_public_on_demand_cost) AS sum_pricing_public_on_demand_cost, | |
| savings_plan_savings_plan_rate, | |
| SUM(savings_plan_savings_plan_effective_cost) AS sum_savings_plan_savings_plan_effective_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_line_item_type LIKE 'SavingsPlanCoveredUsage' | |
| GROUP BY | |
| bill_payer_account_id, | |
| bill_billing_period_start_date, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| savings_plan_savings_plan_a_r_n, | |
| line_item_product_code, | |
| line_item_usage_type, | |
| line_item_unblended_rate, | |
| line_item_line_item_description, | |
| pricing_public_on_demand_rate, | |
| savings_plan_savings_plan_rate | |
| ORDER BY | |
| sum_pricing_public_on_demand_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query focuses on surfacing accounts which have utilized AWS Savings Plans for which they are not a buyer.? | |
| COMPLETION: SELECT | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| split(savings_plan_savings_plan_a_r_n,':')[5] AS savings_plan_owner_account_id, | |
| savings_plan_offering_type, | |
| line_item_resource_id, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16, 8))) AS sum_line_item_unblended_cost, | |
| SUM(CAST(savings_plan_savings_plan_effective_cost AS DECIMAL(16, 8))) AS sum_savings_plan_savings_plan_effective_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND bill_payer_account_id = '111122223333' | |
| AND line_item_usage_account_id = '444455556666' | |
| AND line_item_line_item_type = 'SavingsPlanCoveredUsage' | |
| AND savings_plan_savings_plan_a_r_n NOT LIKE '%444455556666%' | |
| GROUP BY | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| line_item_resource_id, | |
| line_item_usage_account_id, | |
| split(savings_plan_savings_plan_a_r_n,':')[5], | |
| bill_payer_account_id, | |
| savings_plan_offering_type | |
| ORDER BY | |
| sum_savings_plan_savings_plan_effective_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query focuses on Lambda and the breakdown of its costs by different usage element. Split by Resource IDs you can view the usage, unblended costs and amortized cost broken down by different pricing plans. These results will be ordered by date and costs.? | |
| COMPLETION: SELECT * | |
| FROM | |
| ( | |
| ( | |
| SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_region, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%Lambda-Edge-GB-Second%' THEN 'Lambda EDGE GB x Sec.' | |
| WHEN line_item_usage_type LIKE '%Lambda-Edge-Request%' THEN 'Lambda EDGE Requests' | |
| WHEN line_item_usage_type LIKE '%Lambda-GB-Second%' THEN 'Lambda GB x Sec.' | |
| WHEN line_item_usage_type LIKE '%Request%' THEN 'Lambda Requests' | |
| WHEN line_item_usage_type LIKE '%In-Bytes%' THEN 'Data Transfer (IN)' | |
| WHEN line_item_usage_type LIKE '%Out-Bytes%' THEN 'Data Transfer (Out)' | |
| WHEN line_item_usage_type LIKE '%Regional-Bytes%' THEN 'Data Transfer (Regional)' | |
| ELSE 'Other' | |
| END AS case_line_item_usage_type, | |
| line_item_resource_id, | |
| pricing_term, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_savings_plan_effective_cost | |
| WHEN line_item_line_item_type = 'SavingsPlanRecurringFee' THEN savings_plan_total_commitment_to_date - savings_plan_used_commitment | |
| WHEN line_item_line_item_type = 'SavingsPlanNegation' THEN 0 | |
| WHEN line_item_line_item_type = 'SavingsPlanUpfrontFee' THEN 0 | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost | |
| FROM ${table_name} | |
| WHERE ${date_filter} | |
| AND product_product_name = 'AWS Lambda' | |
| AND line_item_line_item_type LIKE '%Usage%' | |
| AND product_product_family IN ('Data Transfer', 'Serverless') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_region, | |
| 6, -- refers to case_line_item_usage_type | |
| line_item_resource_id, | |
| pricing_term | |
| ) | |
| UNION | |
| ( | |
| SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_region, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%Lambda-Edge-GB-Second%' THEN 'Lambda EDGE GB x Sec.' | |
| WHEN line_item_usage_type LIKE '%Lambda-Edge-Request%' THEN 'Lambda EDGE Requests' | |
| WHEN line_item_usage_type LIKE '%Lambda-GB-Second%' THEN 'Lambda GB x Sec.' | |
| WHEN line_item_usage_type LIKE '%Request%' THEN 'Lambda Requests' | |
| WHEN line_item_usage_type LIKE '%In-Bytes%' THEN 'Data Transfer (IN)' | |
| WHEN line_item_usage_type LIKE '%Out-Bytes%' THEN 'Data Transfer (Out)' | |
| WHEN line_item_usage_type LIKE '%Regional-Bytes%' THEN 'Data Transfer (Regional)' | |
| ELSE 'Other' | |
| END AS case_line_item_usage_type, | |
| line_item_resource_id, | |
| savings_plan_offering_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(savings_plan_savings_plan_effective_cost AS DECIMAL(16,8))) AS sum_savings_plan_savings_plan_effective_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_savings_plan_effective_cost | |
| WHEN line_item_line_item_type = 'SavingsPlanRecurringFee' THEN savings_plan_total_commitment_to_date - savings_plan_used_commitment | |
| WHEN line_item_line_item_type = 'SavingsPlanNegation' THEN 0 | |
| WHEN line_item_line_item_type = 'SavingsPlanUpfrontFee' THEN 0 | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'AWS Lambda' | |
| AND product_product_family IN ('Data Transfer', 'Serverless') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_region, | |
| 6, --refers to case_line_item_usage_type | |
| line_item_resource_id, | |
| savings_plan_offering_type | |
| ) | |
| ) AS aggregatedTable | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will display cost and usage of Elastic Load Balancers which didn’t receive any traffic last month and ran for more than 336 hours (14 days). Resources returned by this query could be considered for deletion.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id, ':', 6) split_line_item_resource_id, | |
| product_region, | |
| pricing_unit, | |
| sum_line_item_usage_amount, | |
| CAST(cost_per_resource AS DECIMAL(16, 8)) AS sum_line_item_unblended_cost | |
| FROM | |
| ( | |
| SELECT | |
| line_item_resource_id, | |
| product_region, | |
| pricing_unit, | |
| line_item_usage_account_id, | |
| bill_payer_account_id, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount, | |
| SUM(SUM(line_item_unblended_cost)) OVER (PARTITION BY line_item_resource_id) AS cost_per_resource, | |
| SUM(SUM(line_item_usage_amount)) OVER (PARTITION BY line_item_resource_id, pricing_unit) AS usage_per_resource_and_pricing_unit, | |
| COUNT(pricing_unit) OVER (PARTITION BY line_item_resource_id) AS pricing_unit_per_resource | |
| FROM | |
| ${table_name} | |
| WHERE | |
| line_item_product_code = 'AWSELB' | |
| -- get previous month | |
| AND month = CAST(month(current_timestamp + -1 * INTERVAL '1' MONTH) AS VARCHAR) | |
| -- get year for previous month | |
| AND year = CAST(year(current_timestamp + -1 * INTERVAL '1' MONTH) AS VARCHAR) | |
| AND line_item_line_item_type = 'Usage' | |
| GROUP BY | |
| line_item_resource_id, | |
| product_region, | |
| pricing_unit, | |
| line_item_usage_account_id, | |
| bill_payer_account_id | |
| ) | |
| WHERE | |
| -- filter only resources which ran more than half month (336 hrs) | |
| usage_per_resource_and_pricing_unit > 336 | |
| AND pricing_unit_per_resource = 1 | |
| ORDER BY | |
| cost_per_resource DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide an inventory for EC2 Savings Plans. It will show useful information about the Savings Plans purchased including ID (ARN), type, term length, commitment (used, hourly, etc…), and utilization. Cost Explorer can also provide this information in the Inventory and Utilization reports however, this combines elements from both into a single report.? | |
| COMPLETION: SELECT | |
| SPLIT_PART(savings_plan_savings_plan_a_r_n, '/', 2) AS split_savings_plan_savings_plan_a_r_n, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m') AS month_line_item_usage_start_date, | |
| savings_plan_offering_type, | |
| savings_plan_region, | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_start_time),'%Y-%m-%d') AS day_savings_plan_start_time, | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_end_time),'%Y-%m-%d') AS day_savings_plan_end_time, | |
| savings_plan_payment_option, | |
| savings_plan_purchase_term, | |
| SUM(TRY_CAST(savings_plan_recurring_commitment_for_billing_period AS DECIMAL(16, 8))) AS sum_savings_plan_recurring_committment_for_billing_period, | |
| SUM(TRY_CAST(savings_plan_total_commitment_to_date AS DECIMAL(16, 8))) AS sum_savings_plan_total_commitment_to_date, | |
| SUM(TRY_CAST(savings_plan_used_commitment AS DECIMAL(16, 8))) AS sum_savings_plan_used_commitment, | |
| AVG(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanRecurringFee' THEN TRY_CAST(savings_plan_total_commitment_to_date AS DECIMAL(8, 2)) | |
| END) AS "Hourly Commitment", | |
| -- (used commitment / total commitment) * 100 = utilization % | |
| TRY_CAST(((SUM(TRY_CAST(savings_plan_used_commitment AS DECIMAL(16, 8))) / SUM(TRY_CAST(savings_plan_total_commitment_to_date AS DECIMAL(16, 8)))) * 100) AS DECIMAL(3, 0)) AS calc_savings_plan_utilization_percent | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND savings_plan_savings_plan_a_r_n <> '' | |
| AND line_item_line_item_type = 'SavingsPlanRecurringFee' | |
| GROUP BY | |
| SPLIT_PART(savings_plan_savings_plan_a_r_n, '/', 2), | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m'), | |
| savings_plan_offering_type, | |
| savings_plan_region, | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_start_time),'%Y-%m-%d'), | |
| DATE_FORMAT(FROM_ISO8601_TIMESTAMP(savings_plan_end_time),'%Y-%m-%d'), | |
| savings_plan_payment_option, | |
| savings_plan_purchase_term | |
| ORDER BY | |
| split_savings_plan_savings_plan_a_r_n, | |
| month_line_item_usage_start_date; | |
| PROMPT: What SQL query corresponds to the following purpose: The Reserved Instance Utilization and Coverage reports are available out-of-the-box in AWS Cost Explorer. This query provides coverage for EC2 Reserved Instances. It shows useful information about the Reserved Instances purchased including Lease ID, instance type and family, used and unused amounts, and On-Demand usage that could be covered by additional Savings Plans if this is your preferred savings method. Reserved Instance Utilization and Coverage reports Cost and Usage columns are dynamic and their visibility in the Athena tables depends on usage. This query will only work if you have reserved instance usage in the table/view you are querying. If you do not have usage you will receive an error that reservation_reservation_a_r_n is an invalid column name. Cost and Usage columns are dynamic and their visibility in the Athena tables depends on usage. This query will only work if you have reserved instance usage in the table/view you are querying. If you do not have usage you will receive an error that reservation_reservation_a_r_n is an invalid column name.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| CASE | |
| WHEN line_item_line_item_type IN ('Usage') THEN 'OnDemand' | |
| WHEN line_item_line_item_type IN ('Fee','RIFee','DiscountedUsage') THEN 'ReservedInstance' | |
| END AS case_purchase_option, | |
| SPLIT_PART(SPLIT_PART(reservation_reservation_a_r_n,':',6),'/',2) AS split_reservation_reservation_a_r_n, | |
| SPLIT_PART(line_item_usage_type ,':',2) AS split_line_item_usage_type_instance_type, | |
| SPLIT_PART(SPLIT_PART(line_item_usage_type ,':',2), '.', 1) AS split_line_item_usage_type_instance_family, | |
| CASE product_region | |
| WHEN NULL THEN 'Global' | |
| WHEN '' THEN 'Global' | |
| ELSE product_region | |
| END AS case_product_region, | |
| line_item_line_item_type, | |
| SUM(TRY_CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(TRY_CAST(reservation_unused_quantity AS DOUBLE)) AS sum_reservation_unused_quantity, | |
| SUM(TRY_CAST(line_item_normalized_usage_amount AS DOUBLE)) AS sum_line_item_normalized_usage_amount, | |
| SUM(TRY_CAST(reservation_unused_normalized_unit_quantity AS DOUBLE)) AS sum_reservation_unused_normalized_unit_quantity, | |
| SUM(CAST(reservation_effective_cost AS DECIMAL(16,8))) AS sum_reservation_effective_cost, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Elastic Compute Cloud' | |
| AND line_item_operation LIKE '%RunInstance%' | |
| AND line_item_line_item_type IN ('Usage','Fee','RIFee','DiscountedUsage') | |
| AND product_product_family NOT IN ('Data Transfer') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| 4, -- refers to case_purchase_option | |
| SPLIT_PART(SPLIT_PART(reservation_reservation_a_r_n,':',6),'/',2), | |
| SPLIT_PART(line_item_usage_type ,':',2), | |
| SPLIT_PART(SPLIT_PART(line_item_usage_type ,':',2), '.', 1), | |
| 8, -- refers to case_product_region | |
| line_item_line_item_type | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| split_line_item_usage_type_instance_type, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: AWS Services running locally on AWS Outposts will be charged on usage only. Operating system charges are billed based on usage as an uplift to cover the license fee and no minimum fee required. This query will provide the Amazon EC2 software costs (like Windows, RHEL or others) on AWS Outposts. These software fees are not included with the cost of the AWS Outposts racks and are billed separately here. The output will include detailed information about the instance type, pre-installed softwares, operating system, description, amortized cost, and usage quantity. The output will be ordered by amortized cost in descending order. AWS Outposts? | |
| COMPLETION: SELECT | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| product_instance_type, | |
| product_operating_system, | |
| product_pre_installed_sw, | |
| line_item_line_item_description, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_savings_plan_effective_cost | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'Usage' THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS sum_amortized_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_location_type='AWS Outposts' | |
| AND product_product_family='Compute Instance' | |
| AND line_item_operation LIKE '%RunInstance%' | |
| AND (line_item_line_item_type = 'Usage' | |
| OR (line_item_line_item_type = 'SavingsPlanCoveredUsage') | |
| OR (line_item_line_item_type = 'DiscountedUsage') | |
| ) | |
| GROUP BY | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| product_instance_type, | |
| product_operating_system, | |
| product_pre_installed_sw, | |
| line_item_line_item_description | |
| ORDER BY | |
| day_line_item_usage_start_date ASC, | |
| sum_amortized_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the daily cost and usage per resource, by operation and service, for Elastic Consainer Services, ECS and EKS, both unblended and amortized costs are shown. To provide you with a complete picture of the data, to match totals in cost explorer, if you are using Savings Plans you will likely see results with blank resource IDs, these represent the Savings Plans Negation values for compute cost already covered by Savings Plans. blank? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id,':',6) AS split_line_item_resource_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_operation, | |
| line_item_product_code, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_savings_plan_effective_cost | |
| WHEN line_item_line_item_type = 'SavingsPlanRecurringFee' THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN line_item_line_item_type = 'SavingsPlanNegation' THEN 0 | |
| WHEN line_item_line_item_type = 'SavingsPlanUpfrontFee' THEN 0 | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| and line_item_product_code IN ('AmazonECS','AmazonEKS') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage','SavingsPlanRecurringFee','SavingsPlanNegation','SavingsPlanUpfrontFee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id,':',6), | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_operation, | |
| line_item_product_code | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost, | |
| sum_line_item_usage_amount, | |
| line_item_operation; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the daily ECS cost and usage per resource, by usage type and purchase option, both unblended and amortized costs are shown. To provide you with a complete picture of the data, to match totals in cost explorer, if you are using Savings Plans you will likely see results with blank resource IDs, these represent the Savings Plans Negation values for compute cost already covered by Savings Plans. blank? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(SPLIT_PART(line_item_resource_id,':',6),'/',2) AS split_line_item_resource_id, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%Fargate-GB%' THEN 'GB per hour' | |
| WHEN line_item_usage_type LIKE '%Fargate-vCPU%' THEN 'vCPU per hour' | |
| END AS case_line_item_usage_type, | |
| CASE line_item_line_item_type | |
| WHEN 'SavingsPlanCoveredUsage' THEN savings_plan_offering_type | |
| WHEN 'SavingsPlanNegation' THEN savings_plan_offering_type | |
| ELSE | |
| CASE pricing_term | |
| WHEN 'OnDemand' THEN 'OnDemand' | |
| WHEN '' THEN 'Spot Instance' | |
| ELSE pricing_term | |
| END | |
| END AS case_purchase_option, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CASE pricing_term | |
| WHEN 'OnDemand' THEN line_item_unblended_cost | |
| WHEN '' THEN line_item_unblended_cost | |
| END) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'SavingsPlanCoveredUsage' THEN savings_plan_savings_plan_effective_cost | |
| WHEN line_item_line_item_type = 'SavingsPlanRecurringFee' THEN savings_plan_total_commitment_to_date - savings_plan_used_commitment | |
| WHEN line_item_line_item_type = 'SavingsPlanNegation' THEN 0 | |
| WHEN line_item_line_item_type = 'SavingsPlanUpfrontFee' THEN 0 | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code IN ('AmazonECS') | |
| AND line_item_operation != 'ECSTask-EC2' | |
| AND product_product_family != 'Data Transfer' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage','SavingsPlanNegation','SavingsPlanRecurringFee','SavingsPlanUpfrontFee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| SPLIT_PART(SPLIT_PART(line_item_resource_id,':',6),'/',2), | |
| 5, --refers to case_line_item_usage_type | |
| 6 -- refers to case_purchase_option | |
| ORDER BY | |
| day_line_item_usage_start_date ASC, | |
| case_purchase_option, | |
| sum_line_item_usage_amount DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: The cost allocation data generated by Amazon ECS split cost allocation analyzes the resource consumption of each container running on an EC2 instance. It calculates costs by considering the amortized cost of the instance and the proportion of CPU and memory resources utilized by the containers. Once split cost allocation data is configured, the AWS Cost and Usage Report will include additional columns that provide detailed insights into container-level costs. These columns offer a comprehensive breakdown of the costs associated with individual containers and their respective resource consumption. Without these columns, this query will generate errors. configured Two new usage records are added for each ECS task per hour as a result, the Cost and Usage Report may be significantly larger after enabling ECS Split Cost Allocation. This published calculation allows customers to estimate the number of new lines. published calculation? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_usage_type, | |
| SPLIT_PART(line_item_resource_id,':',6) AS split_line_item_resource_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m') AS month_line_item_usage_start_date, | |
| line_item_operation, | |
| line_item_product_code, | |
| split_line_item_parent_resource_id, | |
| SUM(CAST(split_line_item_split_usage AS DECIMAL(16,8))) AS sum_split_line_item_split_usage, | |
| SUM(CAST(split_line_item_split_cost AS DECIMAL(16,8))) AS sum_split_line_item_split_cost, | |
| SUM(CAST(split_line_item_unused_cost AS DECIMAL(16,8))) sum_split_line_item_unused_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| and line_item_product_code IN ('AmazonECS') AND line_item_operation like 'ECSTask%' | |
| and split_line_item_split_usage !='' and split_line_item_split_cost !='' and split_line_item_unused_cost !='' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_usage_type, | |
| SPLIT_PART(line_item_resource_id,':',6), | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m'), | |
| line_item_operation, | |
| line_item_product_code, | |
| split_line_item_parent_resource_id, | |
| split_line_item_split_usage, | |
| split_line_item_split_cost, | |
| split_line_item_unused_cost | |
| ORDER BY | |
| month_line_item_usage_start_date ASC, | |
| split_line_item_unused_cost DESC, | |
| line_item_operation | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per linked account for Amazon Connect. The output will include specific details about the usage type, usage description, and product usage region. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_region, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%end-customer-mins' THEN 'End customer minutes' | |
| WHEN line_item_usage_type LIKE '%chat-message' THEN 'Chat messages' | |
| WHEN line_item_usage_type LIKE '%did-numbers' THEN 'DID days of use' | |
| WHEN line_item_usage_type LIKE '%tollfree-numbers' THEN 'Toll free days of use' | |
| WHEN line_item_usage_type LIKE '%did-inbound-mins' THEN 'Inbound DID minutes' | |
| WHEN line_item_usage_type LIKE '%outbound-mins' THEN 'Outbound minutes' | |
| WHEN line_item_usage_type LIKE '%tollfree-inbound-mins' THEN 'Inbound Toll Free minutes' | |
| ELSE 'Others' | |
| END AS case_line_item_usage_type, | |
| line_item_line_item_description, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code IN ('AmazonConnect', 'ContactCenterTelecomm') | |
| AND line_item_line_item_type = 'Usage' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_region, | |
| line_item_usage_type, | |
| line_item_line_item_description | |
| ORDER BY | |
| day_line_item_usage_start_date ASC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides a breakdown of costs associated with an Aurora Global Database deployment, excluding backup costs. Output will be grouped by day, account, charge type, usage type, operation, description, and resource ID. Output will be sorted by day, then cost (descending). Aurora Global Databases are comprised of multiple components, each of which appears as a separate line item in CUR. There is no overarching Aurora Global Database resource ID that can be used to filter query output. This means to get an accurate picture of a specific Aurora Global DB deployment, the relevant cluster and database instance resource IDs in each region where the database is replicated must be added to the WHERE filter. Placeholder variables indicated by a dollar sign and curly braces (${ }) appear where resource IDs should be inserted. Placeholder variables must be replaced before the query will run. Note that depending on your deployment model, you may need to add or remove lines from the WHERE filter as indicated. Resource IDs can be retrieved through the console, CLI, SDK, or other tools, as normal. If you only have access to CUR, consider the simple query SELECT DISTINCT(line_item_resource_id) FROM ${table_name} WHERE line_item_product_code = 'AmazonRDS' which will turn up a list of RDS resource IDs. Even in smaller environments the number of resource IDs returned may make it challenging to identify the right resource IDs. In that case, consider adding additional columns to help differentiate and identify the correct resource, such as columns with user-defined cost allocation tags. For example, SELECT DISTINCT(line_item_resource_id), resource_tags_user_name, resource_tags_user_cost_center FROM ${table_name} WHERE line_item_product_code = 'AmazonRDS'. SELECT DISTINCT(line_item_resource_id) FROM ${table_name} WHERE line_item_product_code = 'AmazonRDS' user-defined cost allocation tags SELECT DISTINCT(line_item_resource_id), resource_tags_user_name, resource_tags_user_cost_center FROM ${table_name} WHERE line_item_product_code = 'AmazonRDS' Consider the following Aurora Global DB deployment example: Primary RegionPrimary writer instanceOne reader instanceSecondary Region 1Three reader instancesSecondary Region 2Zero instances (headless) Primary RegionPrimary writer instanceOne reader instance Primary writer instanceOne reader instance Primary writer instance One reader instance Secondary Region 1Three reader instances Three reader instances Three reader instances Secondary Region 2Zero instances (headless) Zero instances (headless) Zero instances (headless) In this example, the following resource IDs would be needed: Primary region cluster IDPrimary region writer instance namePrimary region reader instance nameSecondary region 1 cluster IDSecondary region 1 reader1 instance nameSecondary region 1 reader2 instance nameSecondary region 1 reader3 instance nameSecondary region 2 cluster ID Primary region cluster ID Primary region writer instance name Primary region reader instance name Secondary region 1 cluster ID Secondary region 1 reader1 instance name Secondary region 1 reader2 instance name Secondary region 1 reader3 instance name Secondary region 2 cluster ID? | |
| COMPLETION: SELECT | |
| DATE_TRUNC('day',line_item_usage_start_date) AS day_line_item_usage_start_date, | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| line_item_usage_type, | |
| line_item_operation, | |
| line_item_line_item_description, | |
| line_item_resource_id, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND (line_item_resource_id LIKE '%${primary_cluster_id}%' -- primary region cluster id in format 'cluster-xxxxxxxxxxxxxxxxxxxxxxxx' | |
| OR line_item_resource_id LIKE '%${secondary_cluster_id_1}%' -- secondary region cluster id in format 'cluster-xxxxxxxxxxxxxxxxxxxxxxxx' | |
| OR line_item_resource_id LIKE '%${secondary_cluster_id_n}%' -- additional secondary region cluster id. copy and paste this line once per additional region/cluster | |
| OR line_item_resource_id LIKE '%${primary_cluster_db_instance_name_1}%' -- primary region database instance name. user defined string, e.g 'team-a-mysql-db-1' | |
| OR line_item_resource_id LIKE '%${primary_cluster_db_instance_name_n}%' -- additional primary region database instance name. copy and paste this line once per additional instance | |
| OR line_item_resource_id LIKE '%${secondary_cluster_db_instance_name_1}%' -- secondary region database instance name. user defined string, e.g 'team-a-mysql-db-2'. optional if running headless. | |
| OR line_item_resource_id LIKE '%${secondary_cluster_db_instance_name_n}%' -- additional secondary region database instance name. copy and paste this line once per additional instance | |
| ) | |
| AND line_item_usage_type NOT LIKE '%BackupUsage%' | |
| GROUP BY | |
| DATE_TRUNC('day', line_item_usage_start_date), | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| line_item_usage_type, | |
| line_item_operation, | |
| line_item_line_item_description, | |
| line_item_resource_id | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC | |
| ; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the daily sum per resource for all RDS purchase options across all RDS usage types.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_instance_type, | |
| line_item_operation, | |
| line_item_usage_type, | |
| line_item_line_item_type, | |
| pricing_term, | |
| product_product_family, | |
| SPLIT_PART(line_item_resource_id,':',7) AS split_line_item_resource_id, | |
| product_database_engine, | |
| SUM(CASE WHEN line_item_line_item_type = 'DiscountedUsage' THEN line_item_usage_amount | |
| WHEN line_item_line_item_type = 'Usage' THEN line_item_usage_amount | |
| ELSE 0 | |
| END) AS sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost, | |
| SUM(CASE WHEN line_item_line_item_type = 'RIFee' THEN -reservation_amortized_upfront_fee_for_billing_period | |
| ELSE 0 | |
| END) AS sum_ri_trueup, | |
| SUM(CASE WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS sum_ri_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Relational Database Service' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'Fee', 'RIFee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_instance_type, | |
| line_item_operation, | |
| line_item_usage_type, | |
| line_item_line_item_type, | |
| pricing_term, | |
| product_product_family, | |
| SPLIT_PART(line_item_resource_id,':',7), | |
| product_database_engine | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_amortized_cost; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the total monthly blended costs for RDS grouped by usage type and a specified tag (e.g. Environment:Test,Dev,Prod). The query can be modified to adjust the Cost dataset from Blended to Unblended by adjusting the specified cost column (line_item_blended_cost -> line_item_unblended_cost). This query would be helpful to visualize a quick monthly breakdown of cost components for RDS usage with a specific tag (Environment:Test,Dev,Prod). Blended to Unblended? | |
| COMPLETION: SELECT | |
| line_item_usage_type, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| resource_tags_user_environment, | |
| SUM(CAST(line_item_blended_cost AS DECIMAL(16,8))) AS sum_line_item_blended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code='AmazonRDS' | |
| AND resource_tags_user_environment = 'dev' | |
| GROUP BY | |
| line_item_usage_type, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| resource_tags_user_environment | |
| HAVING | |
| SUM(line_item_blended_cost) > 0 | |
| ORDER BY | |
| line_item_usage_type, | |
| month_line_item_usage_start_date, | |
| resource_tags_user_environment; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the total daily unblended costs for RDS Instances running on AWS Outposts racks. This query will be helpful to visualize a quick breakdown of cost components for RDS usage based on instance type, database engine and deployment option (Multi vs Single-AZ).? | |
| COMPLETION: SELECT | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id,':',7) AS split_line_item_resource_id, | |
| product_instance_type, | |
| product_database_engine, | |
| product_deployment_option, | |
| SUM(CAST(line_item_usage_amount AS double)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS decimal(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_location_type='AWS Outposts' | |
| AND product_product_family='Database Instance' | |
| AND line_item_product_code = 'AmazonRDS' | |
| AND line_item_line_item_type IN ('Usage', 'DiscountedUsage') | |
| GROUP BY | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| product_instance_type, | |
| product_database_engine, | |
| product_deployment_option | |
| ORDER BY | |
| day_line_item_usage_start_date ASC, | |
| sum_line_item_usage_amount DESC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the total monthly sum per resource for all DynamoDB purchase options (including reserved capacity) across all DynamoDB usage types (including data transfer and storage costs). The unblended cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| product_location, | |
| SPLIT_PART(line_item_resource_id, 'table/', 2) AS line_item_resource_id, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%CapacityUnit%' THEN 'DynamoDB Provisioned Capacity' | |
| WHEN line_item_usage_type LIKE '%HeavyUsage%' THEN 'DynamoDB Provisioned Capacity' | |
| WHEN line_item_usage_type LIKE '%RequestUnit%' THEN 'DynamoDB On-Demand Capacity' | |
| WHEN line_item_usage_type LIKE '%TimedStorage%' THEN 'DynamoDB Storage' | |
| WHEN line_item_usage_type LIKE '%TimedBackup%' THEN 'DynamoDB Backups' | |
| WHEN line_item_usage_type LIKE '%TimedPITR%' THEN 'DynamoDB Backups' | |
| WHEN line_item_usage_type like '%DataTransfer%'THEN 'DynamoDB Data Transfer' | |
| ELSE 'DynamoDB Other Usage' | |
| END AS case_line_item_usage_type, | |
| CASE | |
| WHEN line_item_line_item_type LIKE '%Fee' THEN 'DynamoDB Reserved Capacity' | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN 'DynamoDB Reserved Capacity' | |
| ELSE 'DynamoDB Usage' | |
| END AS case_purchase_option, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_blended_cost AS DECIMAL(16,8))) AS sum_line_item_blended_cost, | |
| SUM(CAST(reservation_unused_quantity AS DOUBLE)) AS sum_reservation_unused_quantity, | |
| SUM(CAST(reservation_unused_recurring_fee AS DECIMAL(16,8))) AS sum_reservation_unused_recurring_fee, | |
| reservation_reservation_a_r_n | |
| FROM | |
| ${table_name} | |
| WHERE | |
| {$date_filter} | |
| AND line_item_product_code = 'AmazonDynamoDB' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| product_location, | |
| SPLIT_PART(line_item_resource_id, 'table/', 2), | |
| 6, -- refers to case_line_item_usage_type | |
| 7, -- refers to case_purchase_option | |
| reservation_reservation_a_r_n | |
| ORDER BY | |
| sum_line_item_blended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and amortized cost as well as usage information per linked account for Amazon Redshift. The output will include detailed information about the resource id (cluster name), usage type, and API operation. The usage amount and cost will be summed and the cost will be in descending order. This query includes RI and SP true up which will show any upfront fees to the account that purchased the pricing model.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_instance_type, | |
| SPLIT_PART(line_item_resource_id,':',7) AS split_line_item_resource_id, | |
| line_item_operation, | |
| line_item_usage_type, | |
| line_item_line_item_type, | |
| pricing_term, | |
| product_usage_family, | |
| product_product_family, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN line_item_usage_amount | |
| WHEN line_item_line_item_type = 'Usage' THEN line_item_usage_amount | |
| ELSE 0 | |
| END) AS sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'RIFee' THEN -reservation_amortized_upfront_fee_for_billing_period | |
| ELSE 0 | |
| END) AS sum_ri_trueup, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS ri_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Redshift' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'RIFee', 'Fee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_instance_type, | |
| SPLIT_PART(line_item_resource_id,':',7), | |
| line_item_operation, | |
| line_item_usage_type, | |
| line_item_line_item_type, | |
| pricing_term, | |
| product_usage_family, | |
| product_product_family | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| product_product_family, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the total monthly sum per resource for all Amazon ElastiCache purchase options (including reserved instances) across all ElastiCache instances types. The unblended and amortized cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id,':',7) AS split_line_item_resource_id, | |
| SPLIT_PART(line_item_usage_type ,':',2) AS split_line_item_usage_type, | |
| CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN 'Reserved Instance' | |
| WHEN line_item_line_item_type = 'Usage' THEN 'OnDemand' | |
| ELSE 'Others' | |
| END AS case_purchase_option, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN line_item_usage_amount | |
| WHEN line_item_line_item_type = 'Usage' THEN line_item_usage_amount | |
| ELSE 0 | |
| END) AS sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'DiscountedUsage' THEN reservation_effective_cost | |
| WHEN line_item_line_item_type = 'RIFee' THEN reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS sum_amortized_cost, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'RIFee' THEN -reservation_amortized_upfront_fee_for_billing_period | |
| ELSE 0 | |
| END) AS sum_ri_trueup, | |
| SUM(CASE | |
| WHEN line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '' THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS ri_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon ElastiCache' | |
| AND product_product_family = 'Cache Instance' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'RIFee', 'Fee') | |
| GROUP BY | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_line_item_type, | |
| line_item_resource_id, | |
| line_item_usage_type | |
| ORDER BY | |
| month_line_item_usage_start_date, | |
| sum_line_item_usage_amount DESC, | |
| sum_line_item_unblended_cost; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will output the total daily cost per DocumentDB cluster. The output will include detailed information about the resource id (cluster name) and usage type. The unblended cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(("line_item_usage_start_date"),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id,':',7) AS line_item_resource_id, | |
| line_item_usage_type, | |
| product_region, | |
| line_item_product_code, | |
| sum(CAST(line_item_usage_amount AS double)) AS sum_line_item_usage_amount, | |
| sum(CAST(line_item_unblended_cost AS decimal(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_Name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonDocDB' | |
| AND line_item_line_item_type NOT IN ('Tax','Credit','Refund','Fee','RIFee') | |
| GROUP BY | |
| 1, -- bill_payer_account_id | |
| 2, -- line_item_usage_account_id | |
| 3, -- day_line_item_usage_start_date | |
| 4, -- line_item_resource_id | |
| 5, -- line_item_usage_type | |
| 6, -- product_region | |
| 7 -- line_item_product_code | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide unblended cost and usage information per linked account for Amazon WorkSpaces. The output will include detailed information about the resource id (WorkSpace ID), usage type, running mode, product bundle, and API operation. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id,'/',2) AS split_line_item_resource_id, | |
| SPLIT_PART(product_bundle,'-',1) AS split_product_bundle, | |
| product_operating_system, | |
| product_memory, | |
| product_storage, | |
| product_vcpu, | |
| product_running_mode, | |
| product_license, | |
| product_software_included, | |
| pricing_unit, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon WorkSpaces' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_resource_id, | |
| product_bundle, | |
| product_operating_system, | |
| product_memory, | |
| product_storage, | |
| product_vcpu, | |
| product_running_mode, | |
| product_license, | |
| product_software_included, | |
| pricing_unit | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: AutoStop Workspaces are cost effective when used for several hours per day. If AutoStop Workspaces run for more than 80 hrs per month it is more cost effective to switch to AlwaysOn mode. This query shows AutoStop Workspaces which ran more that 80 hrs in previous month. If the usage pattern for these Workspaces is the same month over month it’s possible to optimize cost by switching to AlwaysOn mode. For example, Windows PowerPro (8 vCPU, 32GB RAM) bundle in eu-west-1 runs for 400 hrs per month. In AutoStop mode it costs $612/month ($8.00/month + 400 * $1.53/hour) while if used in AlwaysOn mode it would cost $141/month.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id, '/', 2) AS split_line_item_resource_id, | |
| product_region, | |
| product_operating_system, | |
| product_bundle_description, | |
| product_software_included, | |
| product_license, | |
| product_rootvolume, | |
| product_uservolume, | |
| pricing_unit, | |
| sum_line_item_usage_amount, | |
| CAST(total_cost_per_resource AS DECIMAL(16, 8)) AS "sum_line_item_unblended_cost(incl monthly fee)" | |
| FROM | |
| ( | |
| SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| product_operating_system, | |
| pricing_unit, | |
| product_region, | |
| product_bundle_description, | |
| product_rootvolume, | |
| product_uservolume, | |
| product_software_included, | |
| product_license, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount, | |
| SUM(SUM(line_item_unblended_cost)) OVER (PARTITION BY line_item_resource_id) AS total_cost_per_resource, | |
| SUM(SUM(line_item_usage_amount)) OVER (PARTITION BY line_item_resource_id, pricing_unit) AS usage_amount_per_resource_and_pricing_unit | |
| FROM | |
| $ {table_name} | |
| WHERE | |
| line_item_product_code = 'AmazonWorkSpaces' | |
| -- get previous month | |
| AND CAST(month AS INT) = CAST(month(current_timestamp + -1 * INTERVAL '1' MONTH) AS INT) | |
| -- get year for previous month | |
| AND CAST(year AS INT) = CAST(year(current_timestamp + -1 * INTERVAL '1' MONTH) AS INT) | |
| AND line_item_line_item_type = 'Usage' | |
| AND line_item_usage_type LIKE '%AutoStop%' | |
| GROUP BY | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| product_operating_system, | |
| pricing_unit, | |
| product_region, | |
| product_bundle_description, | |
| product_rootvolume, | |
| product_uservolume, | |
| bill_payer_account_id, | |
| product_software_included, | |
| product_license | |
| ) | |
| WHERE | |
| -- return only workspaces which ran more than 80 hrs | |
| usage_amount_per_resource_and_pricing_unit > 80 | |
| ORDER BY | |
| total_cost_per_resource DESC, | |
| line_item_resource_id, | |
| line_item_usage_account_id, | |
| product_operating_system, | |
| pricing_unit; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide unblended cost and usage information per linked account for Amazon AppStream 2.0. The output will include detailed information about the product family, product instance type, pricing unit, region along with usage amount. The cost will be summed and in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| product_product_family, -- Stopped Instance, Streaming Instance, User Fees | |
| product_instance_type, -- stream.TYPE.SIZE | |
| pricing_unit, -- Hrs, Users | |
| product_region, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| CASE line_item_line_item_type | |
| WHEN 'DiscountedUsage' THEN SUM(CAST(reservation_effective_cost AS DECIMAL(16,8))) | |
| WHEN 'Usage' THEN SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) | |
| ELSE SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) | |
| END AS sum_line_item_unblended_cost_reservation_effective_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon AppStream' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| product_product_family, | |
| product_instance_type, | |
| pricing_unit, | |
| product_region, | |
| line_item_line_item_type | |
| ORDER BY | |
| month_line_item_usage_start_date, | |
| sum_line_item_usage_amount DESC, | |
| sum_line_item_unblended_cost_reservation_effective_cost, | |
| product_product_family; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and amortized costs per linked account for all services. The query includes ri_sp_trueup and ri_sp_upfront_fees columns to allow you to visualize the difference between unblended and amortized costs. Unblended cost equals usage plus upfront fees. Amortized cost equals usage plus the portion of upfront fees applicable to the period (both used and unused). True-up therefore represents the difference between total upfront fees incurred in the period using an unblended/cash-based accounting model, and the smaller portion of upfront fees applicable to the period using an amortized/accrual-based accounting model. This query excludes discounts, credits, refunds and taxes, as well as Route 53 Domains usage type due to differences in how usage date is recorded between Cost Explorer and CUR. Notes: Notes: Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month.This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month. Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month. current month charges are estimated This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. reservation_reservation_a_r_n? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-01') AS month_line_item_usage_start_date, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS amortized_cost, | |
| (SUM(line_item_unblended_cost) | |
| - SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) | |
| ) AS ri_sp_trueup, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN line_item_unblended_cost | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS ri_sp_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_usage_type != 'Route53-Domains' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage','SavingsPlanNegation','SavingsPlanRecurringFee','SavingsPlanUpfrontFee','RIFee','Fee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| 3 | |
| ORDER BY | |
| month_line_item_usage_start_date ASC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and amortized costs per linked account for all services by region where the service is operating. The query includes ri_sp_trueup and ri_sp_upfront_fees columns to allow you to visualize the difference between unblended and amortized costs. Unblended cost equals usage plus upfront fees. Amortized cost equals usage plus the portion of upfront fees applicable to the period (both used and unused). True-up therefore represents the difference between total upfront fees incurred in the period using an unblended/cash-based accounting model, and the smaller portion of upfront fees applicable to the period using an amortized/accrual-based accounting model. This query excludes discounts, credits, refunds and taxes, as well as Route 53 Domains usage type due to differences in how usage date is recorded between Cost Explorer and CUR. Notes: Notes: Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month.This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month. Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month. current month charges are estimated This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. reservation_reservation_a_r_n? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-01') AS month_line_item_usage_start_date, | |
| CASE product_region | |
| WHEN NULL THEN 'Global' | |
| WHEN '' THEN 'Global' | |
| WHEN 'global' THEN 'Global' | |
| ELSE product_region | |
| END AS product_region, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS amortized_cost, | |
| (SUM(line_item_unblended_cost) | |
| - SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) | |
| ) AS ri_sp_trueup, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN line_item_unblended_cost | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS ri_sp_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_usage_type != 'Route53-Domains' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage','SavingsPlanNegation','SavingsPlanRecurringFee','SavingsPlanUpfrontFee','RIFee','Fee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| 3, | |
| 4; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and amortized costs per linked account for all services by service. Data Transfer is also broken out for each service. The query includes ri_sp_trueup and ri_sp_upfront_fees columns to allow you to visualize the difference between unblended and amortized costs. Unblended cost equals usage plus upfront fees. Amortized cost equals usage plus the portion of upfront fees applicable to the period (both used and unused). True-up therefore represents the difference between total upfront fees incurred in the period using an unblended/cash-based accounting model, and the smaller portion of upfront fees applicable to the period using an amortized/accrual-based accounting model. This query excludes discounts, credits, refunds and taxes, as well as Route 53 Domains usage type due to differences in how usage date is recorded between Cost Explorer and CUR. Notes: Notes: Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month.This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month. Charges for the current billing month may differ slightly when comparing between Cost Explorer and CUR due to differences in how current month charges are estimated. Charges will match between Cost Explorer and CUR once billing has been finalized at the close of the month. current month charges are estimated This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. This query expects that you have reserved instances purchased within at least one of the accounts. Running this query as is without reserved instances in the CUR data set will result in an error. To use this query without reserved instances, remove or comment out lines containing reservation_reservation_a_r_n. reservation_reservation_a_r_n? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-01') AS month_line_item_usage_start_date, | |
| CASE | |
| WHEN (line_item_line_item_type = 'Usage' AND product_product_family = 'Data Transfer') THEN CONCAT('DataTransfer-',line_item_product_code) | |
| ELSE line_item_product_code | |
| END AS service_line_item_product_code, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) AS amortized_cost, | |
| (SUM(line_item_unblended_cost) | |
| - SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN (savings_plan_total_commitment_to_date - savings_plan_used_commitment) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 | |
| ELSE line_item_unblended_cost | |
| END) | |
| ) AS ri_sp_trueup, | |
| SUM(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN line_item_unblended_cost | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN line_item_unblended_cost | |
| ELSE 0 | |
| END) AS ri_sp_upfront_fees | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_usage_type != 'Route53-Domains' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage','SavingsPlanNegation','SavingsPlanRecurringFee','SavingsPlanUpfrontFee','RIFee','Fee') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| 3, | |
| 4 | |
| ORDER BY | |
| month_line_item_usage_start_date ASC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide a monthly cost summary by AWS Service Charge which is an approximation to the monthly bill in the billing console.? | |
| COMPLETION: SELECT | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-01') AS month_line_item_usage_start_date, | |
| bill_bill_type, | |
| CASE | |
| WHEN (product_product_family = 'Data Transfer') THEN 'Data Transfer' | |
| ELSE replace(replace(replace(product_product_name, 'Amazon '),'Amazon'),'AWS ') | |
| END AS product_product_name, | |
| product_location, | |
| line_item_line_item_description, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| GROUP BY | |
| 1, | |
| bill_bill_type, | |
| 3, | |
| product_location, | |
| line_item_line_item_description | |
| HAVING SUM(line_item_usage_amount) > 0 | |
| ORDER BY | |
| month_line_item_usage_start_date, | |
| bill_bill_type, | |
| product_product_name, | |
| product_location, | |
| line_item_line_item_description; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide a monthly individual account chargeback for the premium support cost based on its contribution to overall AWS bill. This query computes the total monthly aws bill (without tax and support charges) and then calculates just the support charges. Based on the Individual accounts usage/spend percentage, its equivalent support fee is computed.? | |
| COMPLETION: SELECT bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| ROUND(total_support_cost *((SUM(line_item_unblended_cost)/total_cost)),2) AS support_cost, | |
| ROUND(SUM(line_item_unblended_cost)/total_cost*100, | |
| 2) AS percentage_of_total_cost, | |
| ${table_name}.year, | |
| ${table_name}.month | |
| FROM ${table_name} | |
| RIGHT JOIN -- Total AWS bill without support | |
| (SELECT SUM(line_item_unblended_cost) AS total_cost, | |
| year, | |
| month | |
| FROM ${table_name} | |
| WHERE line_item_line_item_type <> 'Tax' | |
| AND line_item_product_code <> 'OCBPremiumSupport' | |
| GROUP BY | |
| year, | |
| month) AS aws_total_without_support | |
| ON (${table_name}.year = aws_total_without_support.year AND ${table_name}.month = aws_total_without_support.month) | |
| RIGHT JOIN -- Total support | |
| (SELECT SUM(line_item_unblended_cost) AS total_support_cost, | |
| year, | |
| month | |
| FROM ${table_name} | |
| WHERE line_item_product_code = 'OCBPremiumSupport' | |
| AND line_item_line_item_type <> 'Tax' | |
| GROUP BY year, month ) AS aws_support | |
| ON (${table_name}.year=aws_support.year AND ${table_name}.month = aws_support.month) | |
| WHERE line_item_line_item_type <> 'Tax' | |
| AND line_item_product_code <> 'OCBPremiumSupport' | |
| AND ${table_name}.year = '2020' AND (${table_name}.month BETWEEN '7' AND '9' OR ${table_name}.month BETWEEN '07' AND '09') | |
| GROUP BY | |
| bill_payer_account_id, | |
| total_support_cost, | |
| total_cost, | |
| ${table_name}.year, | |
| ${table_name}.month, | |
| line_item_usage_account_id | |
| ORDER BY | |
| support_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will aggregate charge types for one or more payers. For more information on various charge types please reference our Cost Explorer documentation. This query will replicate Cost Explorer results when filtering by charge type in the cost explore filters as shown below. Cost Explorer documentation In order to obtain more granular data, try adding the column ‘line_item_line_item_description’ into the SELECT and Group By Sections (see example #2). Note: This query expects that you have reserved instances purchased within at least one of the accounts. This query will not run correctly without reserved instances within the CUR data set. Note:? | |
| COMPLETION: SELECT bill_payer_account_id, | |
| CASE | |
| WHEN (line_item_line_item_type = 'Fee' AND product_product_name = 'AWS Premium Support') THEN 'Support fee' | |
| WHEN (line_item_line_item_type = 'Fee' AND reservation_reservation_a_r_n <> '') THEN 'Upfront reservation fee' | |
| ELSE line_item_line_item_type | |
| END charge_type, | |
| round(sum(line_item_unblended_cost),2) sum_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| GROUP BY | |
| bill_payer_account_id, | |
| 2 -- reference to charge_type case statement | |
| ORDER BY | |
| sum_unblended_cost DESC | |
| ; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended cost for all Serverless products in use across all regions. This query is helpful in tracking Serverless product adoption as application teams modernize their applications. You can expand the query to include line_item_usage_account_id to show individual service charges per linked account. This query helps provide a view that is difficult to achieve within Cost Explorer. Serverless products? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| -- if uncommenting, also uncomment three other occurrences of line_item_usage_account_id: | |
| -- two in SELECTs that are UNIONed and one in GROUP BY or ^F. | |
| -- line_item_usage_account_id, | |
| month_line_item_usage_start_date, | |
| line_item_product_code, | |
| split_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS double)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS decimal(16,8))) AS sum_line_item_unblended_cost | |
| FROM ( | |
| SELECT | |
| bill_payer_account_id, | |
| -- line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| line_item_product_code, | |
| CASE REGEXP_REPLACE(SPLIT_PART(line_item_usage_type, ':', 1), '^[^-]*-') | |
| WHEN 'Fargate-GB-Hours' THEN 'Fargate' | |
| WHEN 'Fargate-vCPU-Hours' THEN 'Fargate' | |
| WHEN 'SpotUsage-Fargate-GB-Hours' THEN 'Fargate' | |
| WHEN 'SpotUsage-Fargate-vCPU-Hours' THEN 'Fargate' | |
| ELSE '--' -- should not be reached! | |
| END AS split_line_item_usage_type, | |
| line_item_usage_amount, | |
| line_item_unblended_cost, | |
| year, | |
| month | |
| FROM ${table_name} | |
| WHERE | |
| ( | |
| line_item_line_item_type IN ('DiscountedUsage', | |
| 'Usage', | |
| 'Credit', | |
| 'RIFee', | |
| 'SavingsPlanCoveredUsage', | |
| 'SavingsPlanNegation') | |
| ) | |
| AND | |
| ( | |
| line_item_usage_type LIKE '%Fargate%' AND | |
| line_item_product_code IN ('AmazonECS', 'AmazonEKS') | |
| ) | |
| UNION ALL | |
| SELECT | |
| bill_payer_account_id, | |
| -- line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| line_item_product_code, | |
| CASE SPLIT_PART(line_item_usage_type, ':', 2) | |
| WHEN 'ProxyUsage' THEN 'RDS Proxy Usage' | |
| WHEN 'ServerlessUsage' THEN 'Aurora Serverless' | |
| ELSE '--' | |
| END AS split_line_item_usage_type, | |
| line_item_usage_amount, | |
| line_item_unblended_cost, | |
| year, | |
| month | |
| FROM ${table_name} | |
| WHERE | |
| ( | |
| line_item_line_item_type IN ('DiscountedUsage', | |
| 'Usage', | |
| 'Credit', | |
| 'RIFee', | |
| 'SavingsPlanCoveredUsage', | |
| 'SavingsPlanNegation') | |
| ) | |
| AND | |
| ( | |
| ( | |
| line_item_product_code = 'AmazonRDS' AND | |
| SPLIT_PART(line_item_usage_type, ':', 2) IN ('ServerlessUsage', 'ProxyUsage') | |
| ) | |
| OR | |
| ( | |
| line_item_product_code IN ('AmazonDynamoDB', 'AmazonDAX', | |
| 'AmazonS3', 'AWSAppSync', | |
| 'AmazonApiGateway', | |
| 'Amazon Simple Notification Service', | |
| 'AWSQueueService', 'AWSLambda', | |
| 'AWSEvents' | |
| ) | |
| ) | |
| ) | |
| ) | |
| WHERE | |
| ${date_filter} | |
| GROUP BY | |
| bill_payer_account_id, | |
| -- line_item_usage_account_id, | |
| month_line_item_usage_start_date, | |
| line_item_product_code, | |
| split_line_item_usage_type | |
| ORDER BY | |
| month_line_item_usage_start_date, | |
| line_item_product_code, | |
| split_line_item_usage_type | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides amortized cost by charge type for a given month. The output includes payer account ID, the month, charge types and the amortized cost for the charge type. It closely matches Cost Explorer result when “show costs as” amortized cost is selected under the advanced options and grouped by charge type.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| CASE | |
| WHEN (line_item_line_item_type = 'Fee' AND product_product_name = 'AWS Premium Support') THEN 'Support fee' | |
| WHEN (line_item_line_item_type = 'Fee' AND bill_billing_entity <> 'AWS') THEN 'Marketplace fee' | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN 'Reservation applied usage' | |
| ELSE line_item_line_item_type | |
| END charge_type, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m') AS month_line_item_usage_start_date | |
| , | |
| round(sum(CASE | |
| WHEN (line_item_line_item_type = 'SavingsPlanCoveredUsage') THEN savings_plan_savings_plan_effective_cost | |
| WHEN (line_item_line_item_type = 'SavingsPlanRecurringFee') THEN round((savings_plan_total_commitment_to_date - savings_plan_used_commitment),8) | |
| WHEN (line_item_line_item_type = 'SavingsPlanNegation') THEN 0 | |
| WHEN (line_item_line_item_type = 'SavingsPlanUpfrontFee') THEN 0 | |
| WHEN (line_item_line_item_type = 'DiscountedUsage') THEN reservation_effective_cost | |
| WHEN (line_item_line_item_type = 'RIFee') THEN (reservation_unused_amortized_upfront_fee_for_billing_period + reservation_unused_recurring_fee) | |
| WHEN ((line_item_line_item_type = 'Fee') AND (reservation_reservation_a_r_n <> '')) THEN 0 ELSE line_item_unblended_cost END),2) sum_amortized_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| GROUP BY | |
| bill_payer_account_id, | |
| 2, -- month_line_item_usage_start_date | |
| 3 -- sum_amortized_cost | |
| ORDER BY | |
| sum_amortized_cost DESC | |
| ; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information per linked account for Amazon Rekognition. The output will include detailed information about the usage type and usage region. The cost will be summed by day, account, and usage type, and displayed in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_usage_type, | |
| product_region, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| {$table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonRekognition' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| product_region | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per resource ID for Amazon SageMaker. The output will include detailed information about associated usage types. The cost and usage will be summed by day, account, resource ID, and usage type, and displayed in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| {$table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonSageMaker' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_resource_id, | |
| line_item_usage_type | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information per linked account for Amazon Textract. The output will include detailed information about the usage type and usage region. The cost and usage will be summed by day, account, and usage type, and displayed in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_usage_type, | |
| product_region, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| {$table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonTextract' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| product_region | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended and usage information per linked account for AWS Config. The output will include detailed information about the usage type and usage region. The cost will be summed by day, account, and usage type.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_region, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%%ConfigurationItemRecorded%%' THEN 'ConfigurationItemRecorded' | |
| WHEN line_item_usage_type LIKE '%%ActiveConfigRules%%' THEN 'ActiveConfigRules' | |
| WHEN line_item_usage_type LIKE '%%SecurityHubConfigRules%%' THEN 'SecurityHubConfigRules' | |
| WHEN line_item_usage_type LIKE '%%ConfigRuleEvaluations%%' THEN 'ConfigRuleEvaluations' | |
| ELSE 'Others' | |
| END AS case_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| (year = '2020' AND month IN ('1','01') OR year = '2020' AND month IN ('2','02')) | |
| AND product_product_name = 'AWS Config' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_region, | |
| line_item_usage_type | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost, | |
| case_line_item_usage_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and usage information per linked account for AWS CloudTrail. The output will include detailed information about the usage type and usage region. The cost will be summed by month, account, and usage type, and displayed in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| product_product_name, | |
| SPLIT_PART(line_item_usage_type,'-',2) AS split_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'AWS CloudTrail' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| SPLIT_PART(line_item_usage_type,'-',2), | |
| product_product_name | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC, | |
| month_line_item_usage_start_date, | |
| sum_line_item_usage_amount; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide monthly unblended and usage information per linked account for AWS CloudWatch. The output will include detailed information about the usage type. The cost will be summed by month, account, and usage type, and displayed in descending order. Resource ID can also be included by uncommenting the appropriate lines in the query. Resource ID can also be included by uncommenting the appropriate lines in the query.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') month_line_item_usage_start_date, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%%Requests%%' THEN 'Requests' | |
| WHEN line_item_usage_type LIKE '%%DataProcessing-Bytes%%' THEN 'DataProcessing' | |
| WHEN line_item_usage_type LIKE '%%TimedStorage-ByteHrs%%' THEN 'Storage' | |
| WHEN line_item_usage_type LIKE '%%DataScanned-Bytes%%' THEN 'DataScanned' | |
| WHEN line_item_usage_type LIKE '%%AlarmMonitorUsage%%' THEN 'AlarmMonitors' | |
| WHEN line_item_usage_type LIKE '%%DashboardsUsageHour%%' THEN 'Dashboards' | |
| WHEN line_item_usage_type LIKE '%%MetricMonitorUsage%%' THEN 'MetricMonitor' | |
| WHEN line_item_usage_type LIKE '%%VendedLog-Bytes%%' THEN 'VendedLogs' | |
| WHEN line_item_usage_type LIKE '%%GMD-Metrics%%' THEN 'GetMetricData' | |
| ELSE 'Others' | |
| END AS line_item_usage_type, | |
| -- if uncommenting, also uncomment one other occurrence of line_item_resource_id in GROUP BY | |
| -- SPLIT_PART(line_item_resource_id,':',7) as ResourceID, | |
| line_item_operation, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'AmazonCloudWatch' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| line_item_usage_type, | |
| -- line_item_resource_id, | |
| line_item_operation | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: Amazon Web Services publishes our most up-to-the-minute information on our Service Health Dashboard. This dashboard is based on region and service. While we try to notify you of ongoing problems that may be impactful to your workloads via your Personal Health Dashboard you may want to proactively check where you currently have service usage and cost that may be impacted by our event or another regional issue. Service Health Dashboard Personal Health Dashboard This Regional Service Usage Mapping query transforms your billing data into a summarized view of your usage of AWS services by region and availability zone, providing your operations teams with the ability to respond quickly and accurately during impacting service events.? | |
| COMPLETION: SELECT | |
| CASE | |
| WHEN (bill_billing_entity = 'AWS Marketplace' AND line_item_line_item_type NOT LIKE '%Discount%') THEN product_product_name | |
| WHEN (product_product_name = '') THEN line_item_product_code | |
| ELSE product_product_name | |
| END AS product_name, | |
| CASE product_region | |
| WHEN NULL THEN 'Global' | |
| WHEN '' THEN 'Global' | |
| WHEN 'global' THEN 'Global' | |
| ELSE product_region | |
| END AS product_region, | |
| line_item_availability_zone, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| 1, | |
| line_item_product_code, | |
| line_item_availability_zone, | |
| product_region | |
| HAVING | |
| SUM(line_item_unblended_cost) > 0 | |
| ORDER BY | |
| product_region, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will return a the percentage of resources which are tagged by linked account and product for a specific tag. This will help you determine how good your tagging quality is. For example, if they wish to use to use this field for chargeback or automation. Currently this using the resource_tags_user_name tag but this can be swapped out for any other tags in your CUR. To see these tags use this query: resource_tags_user_name SELECT column_name | |
| FROM information_schema.columns | |
| WHERE table_schema = '${database_name}' | |
| AND table_name = '${table_name}' | |
| AND column_name LIKE 'resource_tags%' | |
| SELECT column_name | |
| FROM information_schema.columns | |
| WHERE table_schema = '${database_name}' | |
| AND table_name = '${table_name}' | |
| AND column_name LIKE 'resource_tags%' | |
| SELECT column_name | |
| FROM information_schema.columns | |
| WHERE table_schema = '${database_name}' | |
| AND table_name = '${table_name}' | |
| AND column_name LIKE 'resource_tags%' | |
| SELECT FROM WHERE = '${database_name}' AND = '${table_name}' AND LIKE 'resource_tags%'? | |
| COMPLETION: WITH allresources AS ( | |
| SELECT | |
| line_item_usage_account_id | |
| , line_item_product_code | |
| , count(DISTINCT line_item_resource_id) AS count_resource | |
| , CASE | |
| WHEN resource_tags_user_name = '' THEN 'NoTag' | |
| ELSE 'Tag' | |
| END AS Tag_Status | |
| FROM ${table_name} | |
| WHERE ${date_filter} | |
| GROUP BY line_item_usage_account_id, line_item_product_code, 4 -- 4 represents the Tag_Status column | |
| ) | |
| SELECT | |
| line_item_usage_account_id | |
| , line_item_product_code | |
| , sum(count_resource) AS "resources" | |
| , sum(CASE WHEN Tag_Status = 'Tag' THEN count_resource ELSE 0 END) AS "tagged_resources" | |
| , round(sum(CASE WHEN Tag_Status = 'Tag' THEN CAST(count_resource AS double) ELSE 0. END)/ sum(count_resource) * 100., 1) AS "percentage_tagged" | |
| FROM allresources | |
| GROUP BY 1,2 | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Amazon API Gateway usage including the resource id. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id, 'apis/', 2) AS split_line_item_resource_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%%ApiGatewayRequest%%' OR line_item_usage_type LIKE '%%ApiGatewayHttpRequest%%' THEN 'Requests' | |
| WHEN line_item_usage_type LIKE '%%DataTransfer%%' THEN 'Data Transfer' | |
| WHEN line_item_usage_type LIKE '%%Message%%' THEN 'Messages' | |
| WHEN line_item_usage_type LIKE '%%Minute%%' THEN 'Minutes' | |
| WHEN line_item_usage_type LIKE '%%CacheUsage%%' THEN 'Cache Usage' | |
| ELSE 'Other' | |
| END AS case_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon API Gateway' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d'), | |
| line_item_resource_id, | |
| line_item_usage_type | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Amazon CloudFront usage including the distribution name, region, and operation. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_region, | |
| product_product_family, -- NOTE: product_product_family used in place of large line_item_usage_type CASE | |
| line_item_operation, | |
| SPLIT_PART(line_item_resource_id, 'distribution/', 2) AS split_line_item_resource_id, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonCloudFront' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d'), | |
| product_region, | |
| product_product_family, | |
| line_item_operation, | |
| line_item_resource_id | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Data Transfer usage including resource id that sourced the traffic, the product code corresponding to the source traffic, and the to/from locations of the usage. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| line_item_product_code, | |
| line_item_usage_account_id , | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS date_line_item_usage_start_date, | |
| line_item_usage_type, | |
| product_from_location, | |
| product_to_location, | |
| product_product_family, | |
| line_item_resource_id, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_family = 'Data Transfer' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| line_item_product_code, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date, '%Y-%m-%d'), | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| product_from_location, | |
| product_to_location, | |
| product_product_family | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides monthly unblended cost and usage information about Data Transfer Regional (Inter AZ) usage including resource id that sourced the traffic and the product code corresponding to the source traffic. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m') AS day_line_item_usage_start_date, | |
| line_item_product_code, | |
| product_product_family, | |
| product_region, | |
| line_item_line_item_description, | |
| line_item_resource_id, | |
| sum(line_item_unblended_cost) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_line_item_description LIKE '%regional data transfer%' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m'), | |
| line_item_product_code, | |
| product_product_family, | |
| product_region, | |
| line_item_line_item_description, | |
| line_item_resource_id | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC | |
| ; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides monthly unblended cost and usage information about Data Transfer related to Amazon MSK including resource id. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| line_item_product_code, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS date_line_item_usage_start_date, | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| line_item_line_item_description, | |
| product_product_family, | |
| SUM(line_item_usage_amount)/1024 AS sum_line_item_usage_amount, | |
| ROUND(SUM(line_item_unblended_cost),2) AS sum_line_item_unblended_cost | |
| FROM ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonMSK' | |
| AND line_item_usage_type LIKE '%DataTransfer%' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| line_item_product_code, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date, '%Y-%m-%d'), | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| product_product_family, | |
| line_item_line_item_description | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides monthly unblended cost and usage information about NAT Gateway Usage including resource id. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%%NatGateway-Bytes' THEN 'NAT Gateway Data Processing Charge' -- Charge for per GB data processed by NatGateways | |
| WHEN line_item_usage_type LIKE '%%NatGateway-Hours' THEN 'NAT Gateway Hourly Charge' -- Hourly charge for NAT Gateways | |
| ELSE line_item_usage_type | |
| END AS line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_family = 'NAT Gateway' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| line_item_resource_id, | |
| line_item_usage_type | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC, | |
| sum_line_item_usage_amount; | |
| PROMPT: What SQL query corresponds to the following purpose: This query shows cost and usage of NAT Gateways which didn’t receive any traffic last month and ran for more than 336 hrs. Resources returned by this query could be considered for deletion.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| SPLIT_PART(line_item_resource_id, ':', 6) split_line_item_resource_id, | |
| product_region, | |
| pricing_unit, | |
| sum_line_item_usage_amount, | |
| CAST(cost_per_resource AS DECIMAL(16, 8)) AS sum_line_item_unblended_cost | |
| FROM | |
| ( | |
| SELECT | |
| line_item_resource_id, | |
| product_region, | |
| pricing_unit, | |
| line_item_usage_account_id, | |
| bill_payer_account_id, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount, | |
| SUM(SUM(line_item_unblended_cost)) OVER (PARTITION BY line_item_resource_id) AS cost_per_resource, | |
| SUM(SUM(line_item_usage_amount)) OVER (PARTITION BY line_item_resource_id, pricing_unit) AS usage_per_resource_and_pricing_unit, | |
| COUNT(pricing_unit) OVER (PARTITION BY line_item_resource_id) AS pricing_unit_per_resource | |
| FROM | |
| ${table_name} | |
| WHERE | |
| line_item_product_code = 'AmazonEC2' | |
| AND line_item_usage_type LIKE '%Nat%' | |
| -- get previous month | |
| AND CAST(month AS INT) = CAST(month(current_timestamp + -1 * INTERVAL '1' MONTH) AS INT) | |
| -- get year for previous month | |
| AND CAST(year AS INT) = CAST(year(current_timestamp + -1 * INTERVAL '1' MONTH) AS INT) | |
| AND line_item_line_item_type = 'Usage' | |
| GROUP BY | |
| line_item_resource_id, | |
| product_region, | |
| pricing_unit, | |
| line_item_usage_account_id, | |
| bill_payer_account_id | |
| ) | |
| WHERE | |
| -- filter only resources which ran more than half month (336 hrs) | |
| usage_per_resource_and_pricing_unit > 336 | |
| AND pricing_unit_per_resource = 1 | |
| ORDER BY | |
| cost_per_resource DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides monthly unblended cost and usage information about AWS Transit Gateway Usage including attachment type, and resource id. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| CASE | |
| WHEN line_item_resource_id LIKE 'arn%' THEN CONCAT(SPLIT_PART(line_item_resource_id,'/',2),' - ',product_location) | |
| ELSE CONCAT(line_item_resource_id,' - ',product_location) | |
| END AS line_item_resource_id, | |
| product_location, | |
| product_attachment_type, | |
| pricing_unit, | |
| CASE | |
| WHEN pricing_unit = 'hour' THEN 'Hourly charges' | |
| WHEN pricing_unit = 'GigaBytes' THEN 'Data processing charges' | |
| END AS pricing_unit, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_group = 'AWSTransitGateway' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| line_item_resource_id, | |
| product_location, | |
| product_attachment_type, | |
| pricing_unit | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC, | |
| month_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| product_attachment_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about AWS Network Usage including VPCPeering, PublicIP, InterZone, LoadBalancing, and resource id. Usage will be in ascending order and cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_operation, | |
| line_item_resource_id, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_operation IN ( | |
| 'LoadBalancing-PublicIP-In', | |
| 'LoadBalancing-PublicIP-Out', | |
| 'InterZone-In', | |
| 'InterZone-Out', | |
| 'PublicIP-In', | |
| 'PublicIP-Out', | |
| 'VPCPeering-In', | |
| 'VPCPeering-Out' | |
| ) | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_operation, | |
| line_item_resource_id | |
| ORDER BY | |
| day_line_item_usage_start_date ASC, | |
| sum_line_item_usage_amount DESC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query shows cost and usage of inbalance inter-az data transfer last month. These resources are commonly collectors or aggregators mostly receiving data from other resources in different Availability Zones. Distributing the resource functionality to each of the Availability Zones and redirect the data transfer from sending sources to be within the same Availability Zone will eliminate the $0.01/GB data transfer charges between Availability Zones.? | |
| COMPLETION: SELECT | |
| line_item_usage_account_id as "account", | |
| product_region as "region", | |
| line_item_resource_id as "resource", | |
| round (sum (IF ((line_item_operation = 'InterZone-In'), line_item_unblended_cost, 0)), 2) as "interaz_in_cost", | |
| round (sum (IF ((line_item_operation = 'InterZone-Out'), line_item_unblended_cost, 0)), 2) as "interaz_out_cost" | |
| FROM $(table_name) | |
| WHERE (line_item_usage_type LIKE '%DataTransfer-Regional-Bytes%') | |
| and (line_item_line_item_type = 'Usage') | |
| and ((line_item_operation = 'InterZone-In') or (line_item_operation = 'InterZone-Out')) | |
| and (month(bill_billing_period_start_date) = month((current_date) - INTERVAL '1' month)) | |
| and (year(bill_billing_period_start_date) = year((current_date) - INTERVAL '1' month)) | |
| GROUP BY line_item_usage_account_id, product_region, line_item_resource_id | |
| HAVING ((round (sum (IF ((line_item_operation LIKE 'InterZone-In'), line_item_unblended_cost, 0)), 2) / (round (sum (IF ((line_item_operation LIKE 'InterZone-Out'), line_item_unblended_cost, 0)), 2))) > 20) | |
| and ((round (sum (IF ((line_item_operation LIKE 'InterZone-In'), line_item_unblended_cost, 0)), 2)) > 1000) | |
| ORDER BY "interaz_in_cost" DESC, "interaz_out_cost" DESC, account ASC, region ASC, resource ASC | |
| PROMPT: What SQL query corresponds to the following purpose: This query shows cost and usage of Interface Endpoints which did not receive significant traffic last month. Resources returned by this query could be considered for deletion or rearchitecture for centralized deployment.? | |
| COMPLETION: SELECT | |
| line_item_usage_account_id as "account", | |
| product_region as "region", | |
| split_part(line_item_resource_id, ':', 6) as "resource", | |
| round (sum (IF ((line_item_usage_type LIKE '%Endpoint-Hour%'), line_item_unblended_cost, 0)), 2) as "hourly_cost", | |
| round (sum (IF ((line_item_usage_type LIKE '%Endpoint-Bytes%'), line_item_blended_cost, 0)), 2) as "traffic_cost" | |
| FROM ${table_name} | |
| WHERE (line_item_product_code = 'AmazonVPC') | |
| and (line_item_line_item_type = 'Usage') | |
| and ((line_item_usage_type LIKE '%Endpoint-Hour%') or (line_item_usage_type LIKE '%Endpoint-Byte%')) | |
| and (month(bill_billing_period_start_date) = month((current_date) - INTERVAL '1' month)) | |
| and (year(bill_billing_period_start_date) = year((current_date) - INTERVAL '1' month)) | |
| GROUP BY line_item_usage_account_id, product_region, line_item_resource_id | |
| HAVING ((round (sum (IF ((line_item_usage_type LIKE '%Endpoint-Hour%'), line_item_unblended_cost, 0)), 2) / (round (sum (IF ((line_item_usage_type LIKE '%Endpoint-Bytes%'), line_item_blended_cost, 0)), 2))) > 20) | |
| ORDER BY "hourly_cost" DESC, "traffic_cost" DESC, account ASC, region ASC, resource ASC | |
| PROMPT: What SQL query corresponds to the following purpose: This query shows cost and usage of Network Firewall Endpoints which did not receive significant traffic last month. Resources returned by this query could be considered for deletion or rearchitecture for centralized deployment.? | |
| COMPLETION: SELECT | |
| line_item_usage_account_id as "account", | |
| product_region as "region", | |
| split_part(line_item_resource_id, ':', 6) as "resource", | |
| round (sum (IF ((line_item_usage_type LIKE '%Endpoint-Hour%'), line_item_unblended_cost, 0)), 2) as "hourly_cost", | |
| round (sum (IF ((line_item_usage_type LIKE '%Traffic-GB%'), line_item_unblended_cost, 0)), 2) as "traffic_cost" | |
| FROM ${table_name} | |
| WHERE (line_item_product_code = 'AWSNetworkFirewall') | |
| and (line_item_line_item_type = ('Usage')) | |
| and ((line_item_usage_type LIKE '%Endpoint-Hour%') or (line_item_usage_type LIKE '%Traffic-GB%')) | |
| and (month(bill_billing_period_start_date) = month((current_date) - INTERVAL '1' month)) | |
| and (year(bill_billing_period_start_date) = year((current_date) - INTERVAL '1' month)) | |
| GROUP BY line_item_usage_account_id, product_region, line_item_resource_id | |
| HAVING (round (sum (IF ((line_item_usage_type LIKE '%Endpoint-Hour%'), line_item_unblended_cost, 0)), 2)/round (sum (IF ((line_item_usage_type LIKE '%Traffic-GB%'), line_item_unblended_cost, 0)), 2) > 20) | |
| ORDER BY "hourly_cost" DESC, "traffic_cost" DESC, account ASC, region ASC, resource ASC | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about AWS CodeBuild Usage. The usage amount and cost will be summed.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM ${table_name} | |
| WHERE ${date_filter} | |
| AND line_item_product_code = 'CodeBuild' | |
| GROUP BY | |
| 1, 2, 3, 4, 5 | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Amazon GuardDuty Usage. The usage amount and cost will be summed.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_usage_type, | |
| TRIM(REPLACE(product_group, 'Security Services - Amazon GuardDuty ', '')) AS trim_product_group, | |
| pricing_unit, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon GuardDuty' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| product_group, | |
| pricing_unit | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost, | |
| trim_product_group; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Amazon Cognito Usage. The usage amount and cost will be summed.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| product_product_name, | |
| line_item_operation, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Cognito' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| product_product_name, | |
| line_item_operation | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost, | |
| line_item_operation; | |
| PROMPT: What SQL query corresponds to the following purpose: AWS Shield Advanced is a paid service that provides additional protections for internet-facing applications. See AWS Shield Pricing Page for details. AWS Shield Advanced charges a monthly fee, plus a usage fee based on data transfer out. The result generated by the query below will contain the resource’s ID and protected resource type. This information enables customers to identify the primary account and resource responsible for the majority of their AWS Shield cost. AWS Shield Pricing Page? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| line_item_operation, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| line_item_product_code = 'AWSShield' | |
| AND product_product_family IN ('Shield-DataTransfer', 'Shield Advanced Monthly Fee') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| ${date_filter} | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| line_item_resource_id, | |
| line_item_operation | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC, | |
| line_item_resource_id | |
| ; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about AWS WAF Usage including web acl, rule id, and region. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(SPLIT_PART(line_item_resource_id,'/',2),'+',1) AS split_webaclid_line_item_resource_id, | |
| SPLIT_PART(SPLIT_PART(line_item_resource_id,'/',2),'+',2) AS split_ruleid_line_item_resource_id, | |
| line_item_usage_type, | |
| product_group, | |
| product_group_description, | |
| product_location, | |
| product_location_type, | |
| line_item_line_item_description, | |
| pricing_unit, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'AWS WAF' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d'), | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| product_group, | |
| product_group_description, | |
| product_location, | |
| product_location_type, | |
| line_item_line_item_description, | |
| pricing_unit | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost, | |
| product_group; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information for Amazon S3. The output will include detailed information about the resource id (bucket name), operation, and usage type. The usage amount and cost will be summed, and rows will be sorted by cost (descending).? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| line_item_resource_id, | |
| line_item_operation, | |
| CASE | |
| --S3 Early Delete | |
| WHEN line_item_usage_type LIKE '%EarlyDelete-ByteHrs' THEN 'Early Delete Glacier' | |
| WHEN line_item_usage_type LIKE '%EarlyDelete%' THEN 'Early Delete ' || SPLIT_PART(line_item_usage_type,'EarlyDelete-',2) | |
| --S3 Requests | |
| WHEN line_item_usage_type LIKE '%Requests-INT%' THEN 'Requests INT' | |
| WHEN (line_item_usage_type LIKE '%Requests-Tier1' OR line_item_usage_type LIKE '%Requests-Tier2') THEN 'Requests Standard' | |
| WHEN (line_item_usage_type LIKE '%Requests-GLACIER%' OR line_item_usage_type LIKE '%Requests-Tier3' OR line_item_usage_type LIKE '%Requests-Tier5' OR line_item_usage_type LIKE '%Requests-Tier6') THEN 'Requests Glacier' | |
| WHEN line_item_usage_type LIKE '%Requests-GDA%' THEN 'Requests GDA' | |
| WHEN line_item_usage_type LIKE '%Requests-GIR%' THEN 'Requests GIR' | |
| WHEN (line_item_usage_type LIKE '%Requests-Tier4' OR line_item_usage_type LIKE '%Requests-SIA%') THEN 'Requests SIA' | |
| WHEN line_item_usage_type LIKE '%Requests-ZIA%' THEN 'Requests ZIA' | |
| --S3 Retrieval | |
| WHEN (line_item_usage_type LIKE '%Retrieval-Bytes' AND line_item_operation = 'RestoreObject') THEN 'Retrieval Glacier' | |
| WHEN (line_item_usage_type LIKE '%Retrieval-Bytes' AND line_item_operation = 'DeepArchiveRestoreObject') THEN 'Retrieval GDA' | |
| WHEN line_item_usage_type LIKE '%Retrieval%' THEN 'Retrieval ' || SPLIT_PART(line_item_usage_type,'Retrieval-',2) | |
| --S3 Storage | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'StandardStorage') THEN 'Storage Standard' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'StandardIAStorage') THEN 'Storage SIA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'StandardIASizeOverhead') THEN 'Storage SIA-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'OneZoneIAStorage') THEN 'Storage ZIA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'OneZoneIASizeOverhead') THEN 'Storage ZIA-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'GlacierInstantRetrievalStorage') THEN 'Storage GIR' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'GlacierIRSizeOverhead') THEN 'Storage GIR-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'GlacierStorage') THEN 'Storage Glacier' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'GlacierStagingStorage') THEN 'Storage Glacier-Staging' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND (line_item_operation = 'GlacierObjectOverhead' or line_item_operation = 'GlacierS3ObjectOverhead')) THEN 'Storage Glacier-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'RestoreObject') THEN 'Storage Glacier-Restored' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'DeepArchiveStorage') THEN 'Storage GDA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'DeepArchiveStagingStorage') THEN 'Storage GDA-Staging' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND (line_item_operation = 'DeepArchiveObjectOverhead' or line_item_operation = 'DeepArchiveS3ObjectOverhead')) THEN 'Storage GDA-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'DeepArchiveRestoreObject') THEN 'Storage GDA-Restored' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation = 'ReducedRedundancyStorage') THEN 'Storage RRS' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation LIKE 'IntelligentTieringAA%') THEN 'Storage INT-AA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND (line_item_operation = 'IntAAObjectOverhead' or line_item_operation = 'IntAAS3ObjectOverhead')) THEN 'Storage INT-AA-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation LIKE 'IntelligentTieringDAA%') THEN 'Storage INT-DAA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND (line_item_operation = 'IntDAAObjectOverhead' or line_item_operation = 'IntDAAS3ObjectOverhead')) THEN 'Storage INT-DAA-Overhead' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation LIKE 'IntelligentTieringFA%') THEN 'Storage INT-FA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation LIKE 'IntelligentTieringIA%') THEN 'Storage INT-IA' | |
| WHEN (line_item_usage_type LIKE '%TimedStorage%' AND line_item_operation LIKE 'IntelligentTieringAIA%') THEN 'Storage INT-AIA' | |
| --Data Transfer | |
| WHEN line_item_usage_type LIKE '%AWS-In-Bytes%' THEN 'Data Transfer Region to Region (In)' | |
| WHEN line_item_usage_type LIKE '%AWS-In-ABytes%'THEN 'Data Transfer Accelerated Region to Region (In)' | |
| WHEN line_item_usage_type LIKE '%AWS-Out-Bytes%' THEN 'Data Transfer Region to Region (Out)' | |
| WHEN line_item_usage_type LIKE '%AWS-Out-ABytes%' THEN 'Data Transfer Accelerated Region to Region (Out)' | |
| WHEN line_item_usage_type LIKE '%CloudFront-In-Bytes%' THEN 'Data Transfer CloudFront (In)' | |
| WHEN line_item_usage_type LIKE '%CloudFront-Out-Bytes%' THEN 'Data Transfer CloudFront (Out)' | |
| WHEN line_item_usage_type LIKE '%DataTransfer-Regional-Bytes%' THEN 'Data Transfer Inter AZ' | |
| WHEN line_item_usage_type LIKE '%DataTransfer-In-Bytes%' THEN 'Data Transfer Internet (In)' | |
| WHEN line_item_usage_type LIKE '%DataTransfer-Out-Bytes%' THEN 'Data Transfer Internet (Out)' | |
| WHEN line_item_usage_type LIKE '%DataTransfer-In-ABytes%' THEN 'Data Transfer Accelerated Internet (In)' | |
| WHEN line_item_usage_type LIKE '%DataTransfer-Out-ABytes%' THEN 'Data Transfer Accelerated Internet (Out)' | |
| WHEN line_item_usage_type LIKE '%S3RTC-In-Bytes%' THEN 'Data Transfer Replication Time Control (In)' | |
| WHEN line_item_usage_type LIKE '%S3RTC-Out-Bytes%' THEN 'Data Transfer Replication Time Control (Out)' | |
| --S3 Fees & Misc | |
| WHEN line_item_usage_type LIKE '%Monitoring-Automation-INT' THEN 'S3 INT Monitoring Fee' | |
| WHEN line_item_usage_type LIKE '%StorageAnalytics%' THEN 'S3 Storage Analytics' | |
| WHEN line_item_usage_type LIKE '%BatchOperations-Jobs%' THEN 'S3 Batch Operations-Jobs' | |
| WHEN line_item_usage_type LIKE '%BatchOperations-Objects%' THEN 'S3 Batch Operations-Objects' | |
| WHEN line_item_usage_type LIKE '%TagStorage%' THEN 'S3 Tag Storage' | |
| WHEN (line_item_usage_type LIKE '%Select-Returned%' OR line_item_usage_type LIKE '%Select-Scanned%') THEN 'S3 Select' | |
| WHEN line_item_usage_type LIKE '%Inventory%' THEN 'S3 Inventory' | |
| WHEN line_item_operation LIKE '%StorageLens%' THEN 'Storage Lens' | |
| ELSE 'Other ' || line_item_usage_type | |
| END as case_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS double)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS decimal(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_product_code = 'AmazonS3' | |
| AND line_item_line_item_type in ('DiscountedUsage','Usage', 'SavingsPlanCoveredUsage') | |
| AND product_product_family != 'Data Transfer' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_resource_id, | |
| line_item_operation, | |
| 6 --refers to case_line_item_usage_type | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides an overview of cost and usage for Amazon EC2 EBS. Output includes daily unblended cost and usage quantity by payer account, linked account, usage type, and resource ID. The usage amount and cost will be summed, and rows will be sorted by day (ascending), then cost (descending).? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| CASE | |
| WHEN line_item_usage_type LIKE '%SnapshotUsage%' THEN 'Snapshots' | |
| WHEN line_item_usage_type LIKE '%VolumeIOUsage%' THEN 'Magnetic IO' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage' THEN 'Magnetic' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage.gp2' THEN 'GP2' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage.gp3' THEN 'GP3' | |
| WHEN line_item_usage_type LIKE '%VolumeP-IOPS.gp3' THEN 'GP3 IOPS' | |
| WHEN line_item_usage_type LIKE '%VolumeP-Throughput.gp3' THEN 'GP3 Throughput' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage.piops' THEN 'io1' | |
| WHEN line_item_usage_type LIKE '%VolumeP-IOPS.piops' THEN 'io1 IOPS' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage.io2%' THEN 'io2' | |
| WHEN line_item_usage_type LIKE '%VolumeP-IOPS.io2%' THEN 'io2 IOPS' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage.st1' THEN 'st1' | |
| WHEN line_item_usage_type LIKE '%VolumeUsage.sc1' THEN 'sc1' | |
| WHEN line_item_usage_type LIKE '%directAPI%' THEN 'Direct API Requests' | |
| WHEN line_item_usage_type LIKE '%FastSnapshotRestore' THEN 'Fast Snapshot Restore' | |
| ELSE SPLIT_PART(line_item_usage_type,':',2) | |
| END AS case_line_item_usage_type, | |
| CASE | |
| WHEN line_item_resource_id LIKE '%snap%' THEN SPLIT_PART(line_item_resource_id,'/',2) | |
| ELSE line_item_resource_id | |
| END AS case_line_item_resource_id, | |
| SUM(line_item_usage_amount) AS sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost | |
| FROM | |
| {$tableName} | |
| WHERE | |
| {$date_filter} | |
| AND line_item_product_code = 'AmazonEC2' AND line_item_usage_type LIKE '%EBS:%' | |
| AND line_item_line_item_type = 'Usage' | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| 4, --refers to case_line_item_usage_type | |
| 5 --refers to case_line_item_resource_id | |
| ORDER BY | |
| day_line_item_usage_start_date ASC, | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Amazon EBS Snapshot Usage per account including region. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d') AS date_line_item_usage_start_date, | |
| product_region, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Elastic Compute Cloud' | |
| AND line_item_usage_type LIKE '%%EBS%%Snapshot%%' | |
| AND product_product_family LIKE 'Storage Snapshot' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m-%d'), | |
| product_region | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC, | |
| sum_line_item_usage_amount DESC, | |
| date_line_item_usage_start_date ASC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query helps correlate cross-region data transfer cost and usage with EBS Snapshot Copy operations for specific EBS snapshots. Understanding the amount of data transfer associated with specific snapshots, and tangentially how much data change is happening on the associated volume, can be used to inform changes to snapshotting strategy. The query provides total unblended cost and usage information grouped by snapshot, usage type, and line item description. Output is sorted by cost in descending order.? | |
| COMPLETION: SELECT | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| line_item_line_item_description, | |
| SUM(line_item_usage_amount) as sum_line_item_usage_amount, | |
| SUM(line_item_unblended_cost) as sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND line_item_operation = 'EBS Snapshot Copy' | |
| GROUP BY | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| line_item_line_item_description | |
| ORDER BY | |
| SUM(line_item_unblended_cost) DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides daily unblended cost and usage information about Amazon EBS Volume Usage per account. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| CASE SPLIT_PART(line_item_usage_type,':',2) | |
| WHEN 'VolumeUsage' THEN 'EBS - Magnetic' | |
| WHEN 'VolumeIOUsage' THEN 'EBS Magnetic IO' | |
| WHEN 'VolumeUsage.gp2' THEN 'EBS GP2' | |
| WHEN 'VolumeUsage.gp3' THEN 'EBS GP3' | |
| WHEN 'VolumeP-IOPS.gp3' THEN 'EBS GP3 IOPS' | |
| WHEN 'VolumeP-Throughput.gp3' THEN 'EBS GP3 Throughput' | |
| WHEN 'VolumeUsage.piops' THEN 'EBS io1' | |
| WHEN 'VolumeP-IOPS.piops' THEN 'EBS io1 IOPS' | |
| WHEN 'VolumeUsage.io2' THEN 'EBS io2' | |
| WHEN 'VolumeP-IOPS.io2' THEN 'EBS io2 IOPS' | |
| WHEN 'VolumeUsage.st1' THEN 'EBS st1' | |
| WHEN 'VolumeUsage.sc1' THEN 'EBS sc1' | |
| WHEN 'directAPI' THEN 'EBS Direct API Requests' | |
| WHEN 'FastSnapshotRestore' THEN 'EBS Fast Snapshot Restore' | |
| ELSE SPLIT_PART(line_item_usage_type,':',2) | |
| END AS line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Elastic Compute Cloud' | |
| AND line_item_usage_type LIKE '%%EBS%%Volume%%' | |
| AND product_product_family IN ('Storage','System Operation') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m'), | |
| line_item_usage_type | |
| ORDER BY | |
| sum_line_item_unblended_cost DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query provides monthly ratio of unblended cost and usage information between Amazon EBS Volume vs Amazon EBS Snapshots Usage per account and region. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id , | |
| line_item_usage_account_id, | |
| DATE_FORMAT(line_item_usage_start_date,'%Y-%m') AS month_line_item_usage_start_date, | |
| CASE | |
| WHEN product_product_family = 'Storage' THEN 'EBS Volume' | |
| WHEN product_product_family = 'Storage Snapshot' THEN 'EBS Snapshot' | |
| END AS usage_type_product_product_family, | |
| product_region, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${tableName} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Elastic Compute Cloud' | |
| AND (product_product_family = 'Storage Snapshot' OR product_product_family = 'Storage') | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m'), | |
| CASE | |
| WHEN product_product_family = 'Storage' THEN 'EBS Volume' | |
| WHEN product_product_family = 'Storage Snapshot' THEN 'EBS Snapshot' | |
| END, | |
| product_region | |
| ORDER BY | |
| month_line_item_usage_start_date ASC, | |
| sum_line_item_unblended_cost DESC, | |
| sum_line_item_usage_amount DESC; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per linked account for Amazon EFS. The output will include detailed information about the resource id (File System), usage type, and API operation. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id, 'file-system/', 2) AS split_line_item_resource_id, | |
| line_item_usage_type, | |
| product_product_family, | |
| product_storage_class, | |
| pricing_unit, | |
| line_item_operation, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon Elastic File System' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| pricing_unit, | |
| product_product_family, | |
| product_storage_class, | |
| line_item_resource_id, | |
| line_item_operation | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost DESC, | |
| line_item_usage_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per linked account for Amazon FSx. The output will include detailed information about the resource id (FSx file system), usage type, and Storage type. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d') AS day_line_item_usage_start_date, | |
| SPLIT_PART(line_item_resource_id, ':', 6) AS split_line_item_resource_id, | |
| product_deployment_option, | |
| line_item_usage_type, | |
| product_product_family, | |
| pricing_unit, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name = 'Amazon FSx' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| SPLIT_PART(line_item_resource_id, ':', 6), | |
| product_deployment_option, | |
| line_item_usage_type, | |
| product_product_family, | |
| pricing_unit | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will provide daily unblended cost and usage information per linked account for AWS Backup. The output will include detailed information about the usage type, product family, pricing unit and others. The usage amount and cost will be summed and the cost will be in descending order.? | |
| COMPLETION: SELECT | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date), '%Y-%m-%d') AS day_line_item_usage_start_date, | |
| pricing_unit, | |
| product_product_family, | |
| line_item_usage_type, | |
| line_item_operation, | |
| SPLIT_PART(line_item_usage_type, '-', 4) AS split_line_item_usage_type, | |
| SUM(CAST(line_item_usage_amount AS DOUBLE)) AS sum_line_item_usage_amount, | |
| SUM(CAST(line_item_unblended_cost AS DECIMAL(16,8))) AS sum_line_item_unblended_cost | |
| FROM | |
| ${table_name} | |
| WHERE | |
| ${date_filter} | |
| AND product_product_name LIKE '%Backup%' | |
| AND line_item_line_item_type IN ('DiscountedUsage', 'Usage', 'SavingsPlanCoveredUsage') | |
| GROUP BY | |
| bill_payer_account_id, | |
| line_item_usage_account_id, | |
| DATE_FORMAT((line_item_usage_start_date),'%Y-%m-%d'), | |
| line_item_usage_type, | |
| product_product_family, | |
| pricing_unit, | |
| line_item_operation | |
| ORDER BY | |
| day_line_item_usage_start_date, | |
| sum_line_item_usage_amount, | |
| sum_line_item_unblended_cost, | |
| line_item_usage_type; | |
| PROMPT: What SQL query corresponds to the following purpose: This query will display cost and usage of Elastic Block Storage Volumes that are type gp3. These resources returned by this query could be considered for upgrade to gp3 as with up to 20% cost savings, gp3 volumes help you achieve more control over your provisioned IOPS, giving the ability to provision storage with your unique applications in mind. This query uses 0.088 gp3 pricing please check the pricing page to confirm you are using the correct pricing for your applicable region. For Additional information checkout this AWS Blog Post. AWS Blog Post.? | |
| COMPLETION: SELECT * FROM | |
| (SELECT bill_payer_account_id, | |
| line_item_usage_account_id, | |
| product_location, | |
| product_region, | |
| month, | |
| pricing_public_on_demand_rate, | |
| line_item_resource_id, | |
| line_item_usage_type, | |
| SPLIT_PART(SPLIT_PART(line_item_usage_type , | |
| ':',2),'.',2) AS ebs_type, | |
| SUM(line_item_usage_amount) AS gb_charged, | |
| SUM(line_item_unblended_cost) AS sum_line_item_unblended_cost, | |
| SUM(line_item_usage_amount)*.088 AS gp3_price -- 0.088 eu-west-1 pricing | |
| , (SUM(line_item_unblended_cost)-(SUM(line_item_usage_amount)*.088)) AS gp3_savings -- 0.088 eu-west-1 pricing | |
| FROM ${table} | |
| WHERE ${date_filter} | |
| AND product_product_name = 'Amazon Elastic Compute Cloud' | |
| AND line_item_usage_type LIKE '%%EBS%%Volume%%' | |
| AND product_product_family IN ('Storage','System Operation') | |
| AND line_item_line_item_type = ('Usage') | |
| AND product_region = 'eu-west-1' | |
| AND SPLIT_PART(SPLIT_PART(line_item_usage_type,':',2),'.',2) = 'gp2' | |
| GROUP BY bill_payer_account_id, line_item_usage_account_id, month, line_item_usage_type, product_location, product_region, line_item_resource_id, pricing_public_on_demand_rate, month | |
| ORDER BY sum_line_item_unblended_cost DESC) | |
| WHERE gb_charged < 1000; | |