Write a SQL query using window functions to rank users by monthly revenue within each department at Paycom.
Use the provided users, departments, and payments tables. Include users with payment records, assign the same rank to users with equal monthly revenue, and calculate each month independently.
Output
- One row per user, department, and month with payment activity
- Columns:
department_name, revenue_month, user_id, user_name, monthly_revenue, revenue_rank
- Order by department name, month, rank, and user ID