0
0
Snowflakecloud~10 mins

Credit usage monitoring in Snowflake - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to query the total credits used in the current month.

Snowflake
SELECT SUM(credits_used) AS total_credits FROM snowflake.account_usage.warehouse_metering_history WHERE usage_date >= DATE_TRUNC('month', CURRENT_DATE) AND usage_date <= [1];
Drag options to blanks, or click blank then click option'
ACURRENT_DATE
BCURRENT_TIMESTAMP
CCURRENT_TIME
DSYSDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using CURRENT_TIMESTAMP causes type mismatch errors.
Using SYSDATE is not supported in Snowflake.
2fill in blank
medium

Complete the code to filter credit usage for a specific warehouse named 'COMPUTE_WH'.

Snowflake
SELECT usage_date, credits_used FROM snowflake.account_usage.warehouse_metering_history WHERE warehouse_name = [1];
Drag options to blanks, or click blank then click option'
ACOMPUTE_WH
B"COMPUTE_WH"
C`COMPUTE_WH`
D'COMPUTE_WH'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes causes syntax errors.
Not using quotes treats the value as a column name.
3fill in blank
hard

Fix the error in the code to correctly calculate daily credit usage.

Snowflake
SELECT usage_date, SUM(credits_used) [1] daily_credits FROM snowflake.account_usage.warehouse_metering_history GROUP BY usage_date ORDER BY usage_date;
Drag options to blanks, or click blank then click option'
AAS
BBY
CTO
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using BY instead of AS causes syntax errors.
Omitting the alias keyword leads to unclear column names.
4fill in blank
hard

Fill both blanks to create a query that shows credit usage per warehouse for the last 7 days.

Snowflake
SELECT warehouse_name, SUM(credits_used) [1] total_credits FROM snowflake.account_usage.warehouse_metering_history WHERE usage_date >= DATEADD(day, -7, [2]) GROUP BY warehouse_name ORDER BY total_credits DESC;
Drag options to blanks, or click blank then click option'
AAS
BCURRENT_DATE
CCURRENT_TIMESTAMP
DSYSDATE
Attempts:
3 left
💡 Hint
Common Mistakes
Using CURRENT_TIMESTAMP causes time mismatches.
Forgetting the AS keyword causes syntax errors.
5fill in blank
hard

Fill all three blanks to create a query that lists warehouses with credit usage greater than 100 in the last 30 days.

Snowflake
SELECT warehouse_name, SUM(credits_used) [1] total_credits FROM snowflake.account_usage.warehouse_metering_history WHERE usage_date >= DATEADD(day, -30, [2]) GROUP BY warehouse_name HAVING total_credits [3] 100 ORDER BY total_credits DESC;
Drag options to blanks, or click blank then click option'
AAS
BCURRENT_DATE
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > filters the wrong warehouses.
Omitting AS causes syntax errors.
Using CURRENT_TIMESTAMP causes date mismatches.