Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9e533eb

Browse files
Understanding ORDER BY and RANK()
1 parent 8303f66 commit 9e533eb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎data/08-window-functions.sql‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ FROM bookings;
33

44
SELECT booking_date, amount_tipped, SUM(amount_tipped) OVER(PARTITION BY booking_date)
55
FROM bookings;
6+
7+
SELECT booking_date, amount_tipped, SUM(amount_tipped)
8+
OVER(PARTITION BY booking_date ORDER BY amount_billed)
9+
FROM bookings;
10+
11+
SELECT booking_date, amount_tipped, RANK()
12+
OVER(PARTITION BY booking_date ORDER BY amount_tipped DESC)
13+
FROM bookings;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /