Write a query to find the top 3 performing marketing campaigns by revenue for each client in the last 30 days on Attentive.
Use the provided client, campaign, and revenue event data. Treat the last 30 days as beginning at CURRENT_DATE - INTERVAL '30 days'. Break revenue ties by the lower campaign ID.
Output
- One row per qualifying campaign, with
client_name, campaign_id, campaign_name, total_revenue, and campaign_rank.
- Include no more than three campaigns per client, ordered by
client_name, campaign_rank, and campaign_id.