Write a SQL query to join student enrollment and course performance tables and calculate average grade by department for UNC Chapel Hill.
Use the provided enrollment and performance records. Include departments with matching graded performance records and exclude departments with no matching enrollment performance.
department, average_grade.| Column | Type | Description |
|---|---|---|
| enrollment_idPK | INT | Unique identifier for an enrollment |
| student_id | INT | Identifier for the enrolled student |
| department | VARCHAR(100) | Student's UNC Chapel Hill academic department |
| course_code | VARCHAR(20) | Course identifier associated with the enrollment |
| term | VARCHAR(30) | Academic term for the enrollment |
| Column | Type | Description |
|---|---|---|
| performance_idPK | INT | Unique identifier for a performance record |
| enrollment_id | INT | Enrollment associated with the performance record |
| grade | NUMERIC(5,2) | Numeric course grade |