Skip to content

Commit 691eff9

Browse files
authored
Merge branch 'Baeldung:main' into main
2 parents e47e9c4 + 277080a commit 691eff9

File tree

349 files changed

+1998
-179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

349 files changed

+1998
-179
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--using a Common Table Expression
2+
WITH RankedStudents AS (
3+
SELECT
4+
id, name, gpa,
5+
RANK() OVER (ORDER BY gpa DESC) AS r
6+
FROM Student
7+
WHERE gpa IS NOT NULL
8+
)
9+
SELECT id, name, gpa, r
10+
FROM RankedStudents
11+
WHERE r <= 3;
12+
13+
--using a subquery
14+
SELECT *
15+
FROM (
16+
SELECT
17+
id, name, gpa,
18+
RANK() OVER (ORDER BY gpa DESC) AS r
19+
FROM Student
20+
WHERE gpa IS NOT NULL
21+
) AS RankedStudents
22+
WHERE r <= 3;

0 commit comments

Comments
 (0)