22 lines
359 B
SQL
22 lines
359 B
SQL
-- 2. Get N most recent notes (10 rows)
|
|
select
|
|
id as NoteID,
|
|
content as NoteContent,
|
|
timestamp as NoteTimestamp
|
|
from
|
|
(
|
|
select
|
|
n.*,
|
|
ROW_NUMBER() OVER (
|
|
order by
|
|
timestamp desc
|
|
) as rn
|
|
from
|
|
note n
|
|
where
|
|
n.player = $1
|
|
) ranked
|
|
where
|
|
rn <= $2
|
|
order by
|
|
timestamp desc; |