Write a SQL query using window functions to find the top three most active workspaces for each organization over the last 30 days.
Use the organizations, workspaces, and workspace_activity tables. Activity is measured by the number of activity records. Include only workspaces with activity during the period.
Output
- One row per qualifying workspace, with
organization_id, organization_name, workspace_id, workspace_name, activity_count, and activity_rank.
- Return at most three workspaces per organization, ordered by organization, rank, and workspace ID. Break equal activity counts by ascending
workspace_id.