-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jovenc
committed
Jan 21, 2020
1 parent
20ce94d
commit e4a48df
Showing
1 changed file
with
5 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
--Using all data | ||
CREATE TABLE congestion.metrics_test AS | ||
|
||
SELECT segment_id, | ||
time_bin, | ||
SELECT *, | ||
avg_spd / baseline_spd AS tti, | ||
(pct95_tt - avg_tt)/avg_tt AS bi | ||
|
||
FROM ( | ||
SELECT a.segment_id, | ||
a.datetime_bin::time AS time_bin, | ||
COUNT(datetime_bin) AS num_bins, | ||
b.seg_length, | ||
AVG(a.segment_tt_avg_all) AS avg_tt, | ||
PERCENTILE_CONT (0.95) WITHIN GROUP (ORDER BY a.segment_tt_avg_all ASC) AS pct95_tt, | ||
b.seg_length / AVG(a.segment_tt_avg_all) AS avg_spd, | ||
b.seg_length / AVG(a.segment_tt_avg_all) * 3.6 AS avg_spd, | ||
b.spd_baseline_10pct_all AS baseline_spd | ||
FROM congestion.tt_segments_30min_test a | ||
LEFT JOIN congestion.tt_segments_baseline_test b | ||
USING (segment_id) | ||
WHERE a.segment_tt_avg_all IS NOT NULL | ||
GROUP BY segment_id, datetime_bin::time, b.seg_length, b.spd_baseline_10pct_all | ||
ORDER BY segment_id, datetime_bin::time | ||
) abc | ||
) abc |