forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery12.sql
More file actions
26 lines (26 loc) · 684 Bytes
/
query12.sql
File metadata and controls
26 lines (26 loc) · 684 Bytes
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
/* Q12. Trending Posts
\set date '\'2011-07-22T00:00:00.000+00:00\''::timestamp
\set likeThreshold 400
*/
SELECT m.ps_postid AS "message.id"
, m.ps_creationdate AS "message.creationDate"
, c.p_firstname AS "creator.firstName"
, c.p_lastname AS "creator.lastName"
, count(*) as likeCount
FROM post m
, person c -- creator
, likes l
WHERE 1=1
-- join
AND m.ps_creatorid = c.p_personid
AND m.ps_postid = l.l_postid
-- filter
AND m.ps_creationdate > :date
GROUP BY m.ps_postid
, m.ps_creationdate
, c.p_firstname
, c.p_lastname
HAVING count(*) > :likeThreshold
ORDER BY likeCount DESC, m.ps_postid
LIMIT 100
;