0
0
HLDsystem_design~10 mins

Metrics collection in HLD - Interactive Code Practice

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

Complete the code to select all columns from the metrics table.

HLD
SELECT [1] FROM metrics;
Drag options to blanks, or click blank then click option'
A*
BALL
Ccolumns
Dmetrics
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table name instead of '*' to select all columns.
Using 'ALL' which is not valid in this context.
2fill in blank
medium

Complete the code to count the number of entries in the metrics table.

HLD
SELECT COUNT([1]) FROM metrics;
Drag options to blanks, or click blank then click option'
A*
Ball
C1
Dmetric_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using a specific column name which may exclude NULL values.
Using 'all' which is not valid syntax.
3fill in blank
hard

Fix the error in the query to get the average value of the metric column.

HLD
SELECT AVG([1]) FROM metrics;
Drag options to blanks, or click blank then click option'
Ametric_value
Bmetric
Cvalue
Davg
Attempts:
3 left
💡 Hint
Common Mistakes
Using the function name as a column name.
Using a column name that does not exist.
4fill in blank
hard

Fill both blanks to filter metrics collected after 2023-01-01 and order by value descending.

HLD
SELECT * FROM metrics WHERE collected_date [1] '2023-01-01' ORDER BY value [2];
Drag options to blanks, or click blank then click option'
A>
B<
CDESC
DASC
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' to filter dates after a date.
Ordering ascending when descending is needed.
5fill in blank
hard

Fill all three blanks to create a dictionary-like result with metric name as key, average value as value, filtering values above 50.

HLD
SELECT metric_name AS [1], AVG(value) AS [2] FROM metrics WHERE value [3] 50 GROUP BY metric_name;
Drag options to blanks, or click blank then click option'
Akey
Bavg_value
C>
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect aliases that don't describe the columns.
Using '<' instead of '>' in the WHERE clause.