Skip to content

Commit 1e7817e

Browse files
authored
Update Readme.md
1 parent 6647a46 commit 1e7817e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Chapter 9/Readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ FROM STDNT;
202202

203203

204204

205+
**Example 7:** Using the student table in dpu_college db, write a query to find the name and marks of highest scorer from each department.
206+
207+
```sql
208+
WITH CTE AS(
209+
SELECT dept_id, MAX(marks) max_marks
210+
from dpu_college.student
211+
group by dept_id
212+
)
213+
select s.name, c.dept_id, max_marks as marks
214+
from dpu_college.student s
215+
INNER JOIN CTE c ON s.dept_id=c.dept_id AND s.marks=c.max_marks;
216+
```
217+
205218

206219

207220

0 commit comments

Comments
 (0)