Given three relation database tables of employee, salary, and departments, ask to calculate median salary history for each department with SQL.
Use every available salary history record and include departments without salary records.
department_id, department_name, salary_history_count, and median_salaryNULL for their median and a count of zerodepartment_id ascending| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee full name |
| department_id | INT | Department assigned to the employee |
| Column | Type | Description |
|---|---|---|
| salary_idPK | INT | Unique salary history record identifier |
| employee_id | INT | Employee receiving the salary |
| salary_amount | NUMERIC(12,2) | Historical annual salary amount |
| effective_date | DATE | Date the salary became effective |