Advertisement
fkeles

OCI_COST_DATA_MV-2.sql

May 23rd, 2023
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.68 KB | Source Code | 0 0
  1. --my cost by service
  2. SELECT SUBSCRIPTION_ID, --region, compartment_name,
  3.        MIN(INTERVAL_USAGE_START) INTERVAL_USAGE_START, MAX(INTERVAL_USAGE_END) INTERVAL_USAGE_END,
  4.        service_name,
  5.        SUM(MY_COST) MY_COST,CURRENCY_CODE
  6. FROM OCI_COST_DATA_MV
  7. WHERE 1=1
  8. --and service_name in ( 'DATABASE','COMPUTE','NETWORK')
  9. --and compartment_name = 'apex-atp'
  10. AND my_cost != 0
  11. GROUP BY SUBSCRIPTION_ID, service_name, CURRENCY_CODE
  12. ORDER BY 5 DESC
  13.  
  14. -- cost by compartment
  15. SELECT SUBSCRIPTION_ID, compartment_name, --region,
  16.        MIN(INTERVAL_USAGE_START) INTERVAL_USAGE_START, MAX(INTERVAL_USAGE_END) INTERVAL_USAGE_END,
  17.        --service_name,
  18.        SUM(MY_COST) MY_COST,CURRENCY_CODE
  19. FROM OCI_COST_DATA_MV
  20. WHERE 1=1
  21. --and service_name in ( 'DATABASE','COMPUTE','NETWORK')
  22. --and compartment_name = 'apex-atp'
  23. AND my_cost != 0
  24. GROUP BY SUBSCRIPTION_ID, compartment_name, CURRENCY_CODE
  25. ORDER BY 5 DESC
  26.  
  27. -- individual resource's cost details
  28. SELECT SUBSCRIPTION_ID, region, compartment_name, RESOURCE_ID,
  29.        MIN(INTERVAL_USAGE_START) INTERVAL_USAGE_START, MAX(INTERVAL_USAGE_END) INTERVAL_USAGE_END,
  30.        PRODUCT_SKU, PRODUCT_DESCRIPTION, BILLING_UNIT_READABLE, SUM(BILLED_QUANTITY) BILLED_QUANTITY,
  31.        SKU_UNIT_DESCRIPTION, UNIT_PRICE,
  32.        SUM(MY_COST) MY_COST,CURRENCY_CODE
  33. FROM OCI_COST_DATA_MV
  34. WHERE 1=1
  35. --and service_name in ( 'DATABASE','COMPUTE','NETWORK')
  36. --and compartment_name = 'apex-atp'
  37. --and to_char(interval_usage_start) like '11-APR-23%'
  38. AND my_cost != 0
  39. GROUP BY region, compartment_name, RESOURCE_ID,
  40. SUBSCRIPTION_ID, PRODUCT_SKU, PRODUCT_DESCRIPTION, BILLING_UNIT_READABLE, SKU_UNIT_DESCRIPTION, UNIT_PRICE,CURRENCY_CODE
  41. ORDER BY 5,PRODUCT_SKU
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement