forked from ldbc/ldbc_snb_interactive_v1_impls
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery23.sql
More file actions
24 lines (24 loc) · 666 Bytes
/
query23.sql
File metadata and controls
24 lines (24 loc) · 666 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
/* Q23. Holiday destinations
\set country '\'Belarus\''
*/
SELECT count(*) AS messageCount
, dest.pl_name AS "destination.name"
, extract(MONTH FROM m.ps_creationdate) AS month
FROM place pco -- person country
, place pci -- person city
, person p
, post m
, place dest
WHERE 1=1
-- join
AND pco.pl_placeid = pci.pl_containerplaceid
AND pci.pl_placeid = p.p_placeid
AND p.p_personid = m.ps_creatorid
AND m.ps_locationid = dest.pl_placeid
-- filter
AND pco.pl_name = :country
AND m.ps_locationid != pco.pl_placeid
GROUP BY dest.pl_name, month
ORDER BY messageCount DESC, dest.pl_name, month
LIMIT 100
;