Latest Device State

medium · sql, window, analytics

Latest Device State

You are given a stream of device status events.

Schema:

  • device_events(event_id, device_id, customer_id, status, recorded_at)

Create a view named result that returns the latest known status for each device as of 2025-06-01 00:00:00+00.

Return the columns:

  • device_id
  • customer_id
  • last_status
  • last_seen_at

Ignore events after the cutoff. Order results by device_id.

Run tests to see results
No issues detected