NASA's Deep Space Network receives daily quality-controlled signal measurements from instruments supporting missions such as Artemis II and Europa Clipper. Write a PostgreSQL query that calculates each instrument's rolling 7-day signal average and ranks instruments within their mission group for each observation date.
Requirements
- Join missions, instruments, and observations.
- Include only
nominal observations with non-NULL signal values from February 1 through February 10, 2025.
- Aggregate multiple observations for an instrument on the same date before calculating the rolling average. Treat the rolling window as the current date and preceding six calendar days.
- Rank instruments by rolling average within each
mission_group and date, with the highest average ranked first. Use RANK() so ties share a rank.
- Return
mission_group, observation_date, instrument_name, rolling_7_day_avg, and group_rank, ordered by group, date, rank, and instrument name.
Output details
- Round
rolling_7_day_avg to exactly 2 decimal places.
- Average an instrument's available daily averages equally within the 7-day window.
- Order all sort keys ascending, including
mission_group, observation_date, group_rank, and instrument_name.