Write a SQL query that identifies the top 10% of students by GPA within each department.
Use the students and departments tables. Exclude students whose GPA is NULL. For each department, return at least one student when eligible students exist, using student ID as the tie-breaker for an exact cutoff.
student_id, student_name, department_name, gpa, and department_rankdepartment_name, department_rank, and student_id| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Unique department identifier |
| department_name | VARCHAR(100) | Department name |
| Column | Type | Description |
|---|---|---|
| student_idPK | INT | Unique student identifier |
| student_name | VARCHAR(100) | Student full name |
| department_id | INT | Student's department identifier |
| gpa | NUMERIC(3,2) | Student GPA on a 4.00 scale |