Choose the partition Which string is suitable as a somecol definition? score year month…
- User
Choose the partition Which string is suitable as a some_col definition?
score year month id category some_col 8 2019 7 11 a 5 2 2019 7 11 a 3 5 2020 7 12 a 3.5 2 2020 8 13 a 2 10 2021 9 14 b 6 2 2021 9 14 b 2 Select one option from the list Report a typo HINT by avatar Özgür Yıldırım average over the number of rows that can be found. For example, the first row doesn't have any preceding row. The denominator of the average is dynamic; i.e. not always equal to (preceding + following + 1). Was this hint helpful?
AVG(score) OVER (PARTITION BY month ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING) AS some_col
AVG(score) OVER (PARTITION BY year ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) AS some_col
AVG(score) OVER (PARTITION BY category ROWS BETWEEN CURRENT ROW AND 2 FOLLOWING) AS some_col
AVG(score) OVER (PARTITION BY id ROWS BETWEEN CURRENT ROW AND 1 PRECEDING) AS some_col
- Assistant
To choose the appropriate string for the
some_coldefinition based on the hint provided, which discusses an average calculation involving the number of rows that can vary (dynamic denominator), the most suitable option is:AVG(score) OVER (PARTITION BY id ROWS BETWEEN CURRENT ROW AND 1 PRECEDING) AS some_col
This option calculates the average score for each
idand includes the current row and the row preceding it. This matches the hint's description of calculating an average where the number of rows considered can change (dynamic). This approach ensures the calculation adapts depending on the presence of preceding rows.