Back to problems

Compute 7-day rolling complaint/order ratio in SQL

SQL · ByteDance · Medium

Given the tables sellers and events, compute a trailing seven-day complaint-to-order rate for every seller on each day of a fixed reporting range, and additionally one marketplace-wide rate for the range's last day. Each row of events is stamped with a TIMESTAMP value event_time and carries an event_type of either 'order' or 'complaint'. An event is attributed to the calendar day event_time::date. Take 2025-09-01 as the reference day and the reporting range as the seven…

Checking your access…