Snowflake snippets

How to find the list of warehouses and the credit consumption in the last 7 days

If you want to query the Information Schema, table WAREHOUSE_METERING_HISTORY to find the list of warehouses and the credit usage in the last 7 days you can use the following query

SELECT warehouse_name, SUM(credits_used) AS Credits_used
FROM TABLE(
        INFORMATION_SCHEMA.WAREHOUSE_METERING_HISTORY
        (DATEADD('DAYS', -7, CURRENT_DATE())))
GROUP BY warehouse_name
ORDER BY Credits_used DESC;
Snowflake snippet 14

Back to Snowflake cookbook page