Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CREATE TABLE monthly_sales (
sale_id SERIAL PRIMARY KEY,
salesperson VARCHAR(100),
sale_month DATE,
revenue DECIMAL(12,2)
);
INSERT INTO monthly_sales (salesperson, sale_month, revenue) VALUES
('John', '2025-01-01', 12000),
('John', '2025-02-01', 15000),
('Sarah', '2025-01-01', 18000),
('Sarah', '2025-02-01', 22000);
SELECT
salesperson,
sale_month,
revenue,
SUM(revenue) OVER (
PARTITION BY salesperson
ORDER BY sale_month
) AS running_total,
LAG(revenue) OVER (
PARTITION BY salesperson
ORDER BY sale_month
) AS previous_month_revenue,
RANK() OVER (
ORDER BY revenue DESC
) AS revenue_rank
FROM monthly_sales
ORDER BY salesperson, sale_month;Coding works best on desktop or with an external keyboard.
~`
!1
@2
#3
$4
%5
^6
&7
*8
(9
)0
_-
+=
⌫
Tab
Q
W
E
R
T
Y
U
I
O
P
{[
}]
|\
Caps
A
S
D
F
G
H
J
K
L
:;
"'
↵
⇧
Z
X
C
V
B
N
M
<,
>.
?/
⇧
Ctrl
⊞
Alt
␣
Alt
⊞
Ctx
Ctrl
👈Middle
CL Pinky
L Ring
L Middle
L Index
Thumb
R Index
R Middle
R Ring
R Pinky