-
Notifications
You must be signed in to change notification settings - Fork 1
/
query_deelfietsen.txt
46 lines (38 loc) · 1.21 KB
/
query_deelfietsen.txt
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
SELECT * FROM
(SELECT CASE WHEN bike_id = lag(bike_id) THEN ST_DistanceSphere(location, lag(location)
OVER (ORDER BY bike_id, last_time_imported ))
END
FROM bike_detection)
as s1
WHERE s1.distance > 200;
SELECT distinct ON (bike_id) last_time_imported, bike_id,
ST_Y(location), ST_X(location)
FROM bike_detection
WHERE ST_WITHIN(location,
(SELECT geom from municipalities where gm_code='GM0479' and geom is not null limit 1) )
ORDER BY bike_id, last_time_imported DESC;
SELECT * FROM
SELECT (CASE WHEN bike_id = lag(bike_id) THEN ST_DistanceSphere(location, lag(location)
OVER (ORDER BY bike_id, last_time_imported ))
END
FROM bike_detection)
as s1
WHERE s1.distance > 200;
SELECT system_id, bike_id,
ST_Y(location), ST_X(location),
start_time, end_time
FROM park_events
WHERE start_time < %s
AND (end_time > %s OR end_time is null)
AND (true = %s or ST_WITHIN(location,
(SELECT st_union(area)
FROM zones WHERE zone_id IN %s));
SELECT system_id, bike_id,
ST_Y(location), ST_X(location),
start_time, end_time
FROM park_events
WHERE start_time < NOW()
AND (end_time > NOW() OR end_time is null)
AND (true = false or ST_WITHIN(location,
(SELECT st_union(area)
FROM zones WHERE zone_id IN (1,3))));