2 SQL questions like multiple employes sales in each month and how to do with and with out window functions
Asked in the technical_round_2 stage. Reported follow-up: write the same logic in PySpark using data loaded from a CSV or text file in an S3 location.
Write a PostgreSQL query for completed sales from January through March 2025. Return monthly sales per employee and their rank within that month. Also explain how to produce the same result without window functions.
employee_id, employee_name, sales_month, monthly_sales, and monthly_rank.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sale identifier |
| employee_id | INT | Employee associated with the sale |
| sale_date | DATE | Date when the sale occurred |
| amount | NUMERIC(10,2) | Sale amount |
| status | VARCHAR(20) | Sale processing status |