Explain and demonstrate the use of window functions like LEAD, LAG, and RANK in SQL.
Use the supplied employee and monthly usage data. Return each usage record with the previous and next usage value for that employee, plus the employee's usage rank for that month.
employee_id, employee_name, usage_month, usage_gb, previous_usage_gb, next_usage_gb, and monthly_usage_rank.employee_id, then usage_month.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee display name |
| region | VARCHAR(50) | Employee region |
| Column | Type | Description |
|---|---|---|
| usage_idPK | INT | Unique usage record identifier |
| employee_id | INT | Referenced employee identifier |
| usage_month | DATE | Month represented by the record |
| usage_gb | INT | Usage amount in gigabytes |