diff --git a/data/jcp_inm.db b/data/jcp_inm.db index 8132ca8..f5ab3ff 100644 Binary files a/data/jcp_inm.db and b/data/jcp_inm.db differ diff --git a/src/scheme/jcp_inm.scm b/src/scheme/jcp_inm.scm index d075902..a8e8a74 100644 --- a/src/scheme/jcp_inm.scm +++ b/src/scheme/jcp_inm.scm @@ -237,6 +237,36 @@ res)) +; menu-process-data - Process data menu. +; +; Output: +; - Returns an integer corresponding to the menu option selected. +; +(define (menu-process-data) + (let ((res 0)) + (grsp-ld "0 - Main menu.") + (grsp-ld "1 - Process ppers.") + (grsp-ld "2 - Process pvehp.") + (grsp-ld "3 - Process pvehr.") + (set! res (grsp-ask opt)) + res)) + + +; menu-report-data - Report data menu. +; +; Output: +; - Returns an integer corresponding to the menu option selected. +; +(define (menu-report-data) + (let ((res 0)) + (grsp-ld "0 - Main menu.") + (grsp-ld "1 - Report existing ppers.") + (grsp-ld "2 - Report existing pvehp.") + (grsp-ld "3 - Report existing pvehr.") + (set! res (grsp-ask opt)) + res)) + + ; write-prep-sql - Overwrites the contents of prep.sql with the values ; contained in the arguments. ; @@ -311,14 +341,18 @@ database (strings-append (list - "\"INSERT INTO trf_pers (Abr, Alt, Value) VALUES(" + "\"INSERT INTO trf_pers (Abr, Alt, Value, Vehp, Vehr) VALUES(" "'" (ask-street-abr) "', '" (grsp-n2s (ask-street-number)) - "', " + "', '" (grsp-n2s (grsp-ask "Number of people? ")) - ");\"") + "', '" + (grsp-n2s (grsp-ask "Vehicles parked? ")) + "', '" + (grsp-n2s (grsp-ask "Vehicles running? ")) + "');\"") 0) oqc)) @@ -349,23 +383,88 @@ (else (wrch)))))) -; process-data - Data processing sqlp call. +; process-data-opt - Enter block data. allows for data input to trf_pers, and +; batch update with prep.sql once finished entering records. +; +(define (process-data-opt) + (let ((mc -1)) + (while (equal? #f (equal? mc 0)) + (menu-present "Jcp_inm - process data options" pdf "n") + (set! mc (menu-process-data)) + (cond ((equal? mc 0)(grsp-cd "Back to main menu!\n")) + ((equal? mc 1)(process-data1)) + ((equal? mc 2)(process-data2)) + ((equal? mc 3)(process-data3)) + (else (wrch)))))) + + +; report-data-opt - Report data options. ; -(define (process-data) - (grsp-cd "Processing data...\n") +(define (report-data-opt) + (let ((mc -1)) + (while (equal? #f (equal? mc 0)) + (menu-present "Jcp_inm - report data options" pdf "n") + (set! mc (menu-report-data)) + (cond ((equal? mc 0)(grsp-cd "Back to main menu!\n")) + ((equal? mc 1)(report-data1)) + ((equal? mc 2)(report-data2)) + ((equal? mc 3)(report-data3)) + (else (wrch)))))) + + +; process-data1 - Data processing sqlp call, pers. +; +(define (process-data1) + (grsp-cd "Processing data (pers)...\n") (grsp-sqlp sqlp-path database (strings-append (list sql-path "calc.sql") 0) oqc)) -; report-data - Data reporting sqlp call. +; process-data2 - Data processing sqlp call, vehp. ; -(define (report-data) - (grsp-cd "Generating report...\n") +(define (process-data2) + (grsp-cd "Processing data (vehp)...\n") + (grsp-sqlp sqlp-path database (strings-append (list sql-path "calc2.sql") 0) oqc)) + + +; process-data2 - Data processing sqlp call, vehp. +; +(define (process-data3) + (grsp-cd "Processing data (vehr)...\n") + (grsp-sqlp sqlp-path database (strings-append (list sql-path "calc3.sql") 0) oqc)) + + +; report-data1 - Data reporting sqlp call (pers). +; +(define (report-data1) + (grsp-cd "Generating report (pers)...\n") (grsp-sqlp sqlp-path database (strings-append (list sql-path "rep.sql") 0) oqcs) (grsp-sqlp sqlp-path "sqlp_results.txt" "COLS=6" oqcp) (clear) (display (read-file-as-string "sqlp_pretty_tmp.txt")) (grsp-ask "Press to continue.")) - + + +; report-data1 - Data reporting sqlp call (vehp). +; +(define (report-data2) + (grsp-cd "Generating report (vehp)...\n") + (grsp-sqlp sqlp-path database (strings-append (list sql-path "rep2.sql") 0) oqcs) + (grsp-sqlp sqlp-path "sqlp_results.txt" "COLS=6" oqcp) + (clear) + (display (read-file-as-string "sqlp_pretty_tmp.txt")) + (grsp-ask "Press to continue.")) + + +; report-data1 - Data reporting sqlp call (vehr). +; +(define (report-data3) + (grsp-cd "Generating report (vehr)...\n") + (grsp-sqlp sqlp-path database (strings-append (list sql-path "rep3.sql") 0) oqcs) + (grsp-sqlp sqlp-path "sqlp_results.txt" "COLS=6" oqcp) + (clear) + (display (read-file-as-string "sqlp_pretty_tmp.txt")) + (grsp-ask "Press to continue.")) + ; menu-main - Main menu of the program. ; @@ -389,7 +488,7 @@ (set! mc (menu-main)) (cond ((equal? mc 0)(grsp-cd "Bye!\n")) ((equal? mc 1)(enter-data)) - ((equal? mc 2)(process-data)) - ((equal? mc 3)(report-data)) + ((equal? mc 2)(process-data-opt)) + ((equal? mc 3)(report-data-opt)) (else (wrch)))) diff --git a/src/scheme/sqlp_pretty_tmp.txt b/src/scheme/sqlp_pretty_tmp.txt index 5f719d6..cc0e473 100644 --- a/src/scheme/sqlp_pretty_tmp.txt +++ b/src/scheme/sqlp_pretty_tmp.txt @@ -1,59 +1,59 @@ -|R197|1500|109.0|93.0 |MEDIUM|8158.17 -|R197|1400|91.0 |92.0 |MEDIUM|6810.95 -|ZU |5000|85.0 |127.0|HIGH |6361.88 -|RSP |5000|77.0 |160.0|HIGH |5763.11 -|JCP |1700|68.0 |150.0|HIGH |5089.5 -|R197|1600|68.0 |96.0 |MEDIUM|5089.5 -|ALT |1900|67.0 |147.0|HIGH |5014.66 -|RSP |5100|57.0 |194.0|HIGH |4266.2 -|ZU |4900|56.0 |91.0 |MEDIUM|4191.36 -|ALT |1800|55.0 |127.0|HIGH |4116.51 -|GC |5000|51.0 |134.0|HIGH |3817.13 -|MJ |5000|51.0 |101.0|MEDIUM|3817.13 -|ALT |1700|48.0 |112.0|HIGH |3592.59 -|ALT |2000|44.0 |97.0 |MEDIUM|3293.21 -|ALM |5100|43.0 |75.0 |MEDIUM|3218.36 -|R197|1800|43.0 |37.0 |LOW |3218.36 -|RSP |5200|40.0 |102.0|MEDIUM|2993.83 -|R197|1300|39.0 |81.0 |MEDIUM|2918.98 -|R197|1700|37.0 |40.0 |LOW |2769.29 -|JCP |1800|36.0 |95.0 |MEDIUM|2694.44 -|MJ |4900|36.0 |116.0|HIGH |2694.44 -|GCA |6400|32.0 |77.0 |MEDIUM|2395.06 -|MJ |5100|32.0 |92.0 |MEDIUM|2395.06 -|R197|1900|29.0 |37.0 |LOW |2170.52 -|GC |4900|28.0 |120.0|HIGH |2095.68 -|LG |5000|27.0 |40.0 |LOW |2020.83 -|LAV |2000|26.0 |74.0 |MEDIUM|1945.99 -|RSP |4900|26.0 |85.0 |MEDIUM|1945.99 -|ALM |5000|25.0 |54.0 |LOW |1871.14 -|R197|1200|22.0 |53.0 |LOW |1646.6 -|ALM |4900|21.0 |49.0 |LOW |1571.76 -|ALT |2100|21.0 |65.0 |LOW |1571.76 -|GO |4900|21.0 |102.0|MEDIUM|1571.76 -|JCP |1900|20.0 |121.0|HIGH |1496.91 -|JCP |2000|20.0 |115.0|HIGH |1496.91 -|ZA |4900|18.0 |99.0 |MEDIUM|1347.22 -|ALM |4800|17.0 |44.0 |LOW |1272.38 -|GO |5000|17.0 |129.0|HIGH |1272.38 -|LAV |1900|17.0 |82.0 |MEDIUM|1272.38 -|GCA |6600|13.0 |65.0 |LOW |972.99 -|ZU |4800|11.0 |80.0 |MEDIUM|823.3 -|GCA |6500|8.0 |67.0 |LOW |598.77 -|GO |5100|8.0 |102.0|MEDIUM|598.77 -|LG |4900|8.0 |40.0 |LOW |598.77 -|ZA |5000|8.0 |103.0|MEDIUM|598.77 -|GCA |6300|7.0 |75.0 |MEDIUM|523.92 -|JCP |2100|7.0 |59.0 |LOW |523.92 -|COL |1900|6.0 |107.0|MEDIUM|449.07 -|LAV |1800|6.0 |82.0 |MEDIUM|449.07 -|LAV |2100|6.0 |74.0 |MEDIUM|449.07 -|LG |4800|6.0 |34.0 |NONE |449.07 -|COL |2000|4.0 |111.0|HIGH |299.38 -|COL |2100|4.0 |98.0 |MEDIUM|299.38 -|GO |5200|4.0 |81.0 |MEDIUM|299.38 -|LAV |1700|3.0 |79.0 |MEDIUM|224.54 -|MJ |4800|2.0 |80.0 |MEDIUM|149.69 -|ZA |5100|2.0 |97.0 |MEDIUM|149.69 -|ZA |5200|2.0 |97.0 |MEDIUM|149.69 +|R197|1400|19.0|5.0 |NONE|13897.47 +|R197|1500|17.0|5.0 |NONE|12434.58 +|R197|1800|15.0|2.0 |NONE|10971.69 +|R197|1700|14.0|3.0 |NONE|10240.24 +|RSP |5100|14.0|7.0 |NONE|10240.24 +|R197|1600|12.0|6.0 |NONE|8777.35 +|RSP |5200|11.0|6.0 |NONE|8045.9 +|R197|1300|10.0|4.0 |NONE|7314.46 +|RSP |5000|10.0|8.0 |NONE|7314.46 +|R197|1900|9.0 |3.0 |NONE|6583.01 +|ALT |1900|7.0 |9.0 |NONE|5120.12 +|LG |4900|7.0 |3.0 |NONE|5120.12 +|ALT |1700|6.0 |8.0 |NONE|4388.68 +|ALT |1800|6.0 |9.0 |NONE|4388.68 +|LG |4800|6.0 |3.0 |NONE|4388.68 +|GCA |6600|5.0 |3.0 |NONE|3657.23 +|ALT |2000|4.0 |7.0 |NONE|2925.78 +|LG |5000|4.0 |3.0 |NONE|2925.78 +|RSP |4900|4.0 |2.0 |NONE|2925.78 +|R197|1200|3.0 |2.0 |NONE|2194.34 +|ALM |5100|2.0 |6.0 |NONE|1462.89 +|GC |5000|2.0 |11.0|NONE|1462.89 +|GCA |6300|2.0 |3.0 |NONE|1462.89 +|GCA |6400|2.0 |3.0 |NONE|1462.89 +|JCP |1800|2.0 |8.0 |NONE|1462.89 +|JCP |1900|2.0 |8.0 |NONE|1462.89 +|MJ |4900|2.0 |7.0 |NONE|1462.89 +|ALM |5000|1.0 |4.0 |NONE|731.45 +|GC |4900|1.0 |9.0 |NONE|731.45 +|GO |4900|1.0 |4.0 |NONE|731.45 +|GO |5000|1.0 |10.0|NONE|731.45 +|GO |5100|1.0 |6.0 |NONE|731.45 +|GO |5200|1.0 |3.0 |NONE|731.45 +|LAV |1700|1.0 |11.0|NONE|731.45 +|LAV |1800|1.0 |11.0|NONE|731.45 +|LAV |1900|1.0 |9.0 |NONE|731.45 +|LAV |2000|1.0 |10.0|NONE|731.45 +|LAV |2100|1.0 |10.0|NONE|731.45 +|MJ |4800|1.0 |8.0 |NONE|731.45 +|MJ |5000|1.0 |4.0 |NONE|731.45 +|MJ |5100|1.0 |3.0 |NONE|731.45 +|ZA |5100|1.0 |8.0 |NONE|731.45 +|ZU |4800|1.0 |7.0 |NONE|731.45 +|ZU |4900|1.0 |8.0 |NONE|731.45 +|ALM |4800|0.0 |5.0 |NONE|0.0 +|ALM |4900|0.0 |4.0 |NONE|0.0 +|ALT |2100|0.0 |1.0 |NONE|0.0 +|COL |1900|0.0 |7.0 |NONE|0.0 +|COL |2000|0.0 |7.0 |NONE|0.0 +|COL |2100|0.0 |6.0 |NONE|0.0 +|GCA |6500|0.0 |3.0 |NONE|0.0 +|JCP |1700|0.0 |12.0|NONE|0.0 +|JCP |2000|0.0 |9.0 |NONE|0.0 +|JCP |2100|0.0 |4.0 |NONE|0.0 +|ZA |4900|0.0 |8.0 |NONE|0.0 +|ZA |5000|0.0 |8.0 |NONE|0.0 +|ZA |5200|0.0 |8.0 |NONE|0.0 +|ZU |5000|0.0 |9.0 |NONE|0.0 |EOQ | diff --git a/src/scheme/sqlp_results.txt b/src/scheme/sqlp_results.txt index 8ab18c6..237a40a 100644 --- a/src/scheme/sqlp_results.txt +++ b/src/scheme/sqlp_results.txt @@ -1 +1 @@ -R197|1500|109.0|93.0|MEDIUM|8158.17|R197|1400|91.0|92.0|MEDIUM|6810.95|ZU|5000|85.0|127.0|HIGH|6361.88|RSP|5000|77.0|160.0|HIGH|5763.11|JCP|1700|68.0|150.0|HIGH|5089.5|R197|1600|68.0|96.0|MEDIUM|5089.5|ALT|1900|67.0|147.0|HIGH|5014.66|RSP|5100|57.0|194.0|HIGH|4266.2|ZU|4900|56.0|91.0|MEDIUM|4191.36|ALT|1800|55.0|127.0|HIGH|4116.51|GC|5000|51.0|134.0|HIGH|3817.13|MJ|5000|51.0|101.0|MEDIUM|3817.13|ALT|1700|48.0|112.0|HIGH|3592.59|ALT|2000|44.0|97.0|MEDIUM|3293.21|ALM|5100|43.0|75.0|MEDIUM|3218.36|R197|1800|43.0|37.0|LOW|3218.36|RSP|5200|40.0|102.0|MEDIUM|2993.83|R197|1300|39.0|81.0|MEDIUM|2918.98|R197|1700|37.0|40.0|LOW|2769.29|JCP|1800|36.0|95.0|MEDIUM|2694.44|MJ|4900|36.0|116.0|HIGH|2694.44|GCA|6400|32.0|77.0|MEDIUM|2395.06|MJ|5100|32.0|92.0|MEDIUM|2395.06|R197|1900|29.0|37.0|LOW|2170.52|GC|4900|28.0|120.0|HIGH|2095.68|LG|5000|27.0|40.0|LOW|2020.83|LAV|2000|26.0|74.0|MEDIUM|1945.99|RSP|4900|26.0|85.0|MEDIUM|1945.99|ALM|5000|25.0|54.0|LOW|1871.14|R197|1200|22.0|53.0|LOW|1646.6|ALM|4900|21.0|49.0|LOW|1571.76|ALT|2100|21.0|65.0|LOW|1571.76|GO|4900|21.0|102.0|MEDIUM|1571.76|JCP|1900|20.0|121.0|HIGH|1496.91|JCP|2000|20.0|115.0|HIGH|1496.91|ZA|4900|18.0|99.0|MEDIUM|1347.22|ALM|4800|17.0|44.0|LOW|1272.38|GO|5000|17.0|129.0|HIGH|1272.38|LAV|1900|17.0|82.0|MEDIUM|1272.38|GCA|6600|13.0|65.0|LOW|972.99|ZU|4800|11.0|80.0|MEDIUM|823.3|GCA|6500|8.0|67.0|LOW|598.77|GO|5100|8.0|102.0|MEDIUM|598.77|LG|4900|8.0|40.0|LOW|598.77|ZA|5000|8.0|103.0|MEDIUM|598.77|GCA|6300|7.0|75.0|MEDIUM|523.92|JCP|2100|7.0|59.0|LOW|523.92|COL|1900|6.0|107.0|MEDIUM|449.07|LAV|1800|6.0|82.0|MEDIUM|449.07|LAV|2100|6.0|74.0|MEDIUM|449.07|LG|4800|6.0|34.0|NONE|449.07|COL|2000|4.0|111.0|HIGH|299.38|COL|2100|4.0|98.0|MEDIUM|299.38|GO|5200|4.0|81.0|MEDIUM|299.38|LAV|1700|3.0|79.0|MEDIUM|224.54|MJ|4800|2.0|80.0|MEDIUM|149.69|ZA|5100|2.0|97.0|MEDIUM|149.69|ZA|5200|2.0|97.0|MEDIUM|149.69|EOQ| +R197|1400|19.0|5.0|NONE|13897.47|R197|1500|17.0|5.0|NONE|12434.58|R197|1800|15.0|2.0|NONE|10971.69|R197|1700|14.0|3.0|NONE|10240.24|RSP|5100|14.0|7.0|NONE|10240.24|R197|1600|12.0|6.0|NONE|8777.35|RSP|5200|11.0|6.0|NONE|8045.9|R197|1300|10.0|4.0|NONE|7314.46|RSP|5000|10.0|8.0|NONE|7314.46|R197|1900|9.0|3.0|NONE|6583.01|ALT|1900|7.0|9.0|NONE|5120.12|LG|4900|7.0|3.0|NONE|5120.12|ALT|1700|6.0|8.0|NONE|4388.68|ALT|1800|6.0|9.0|NONE|4388.68|LG|4800|6.0|3.0|NONE|4388.68|GCA|6600|5.0|3.0|NONE|3657.23|ALT|2000|4.0|7.0|NONE|2925.78|LG|5000|4.0|3.0|NONE|2925.78|RSP|4900|4.0|2.0|NONE|2925.78|R197|1200|3.0|2.0|NONE|2194.34|ALM|5100|2.0|6.0|NONE|1462.89|GC|5000|2.0|11.0|NONE|1462.89|GCA|6300|2.0|3.0|NONE|1462.89|GCA|6400|2.0|3.0|NONE|1462.89|JCP|1800|2.0|8.0|NONE|1462.89|JCP|1900|2.0|8.0|NONE|1462.89|MJ|4900|2.0|7.0|NONE|1462.89|ALM|5000|1.0|4.0|NONE|731.45|GC|4900|1.0|9.0|NONE|731.45|GO|4900|1.0|4.0|NONE|731.45|GO|5000|1.0|10.0|NONE|731.45|GO|5100|1.0|6.0|NONE|731.45|GO|5200|1.0|3.0|NONE|731.45|LAV|1700|1.0|11.0|NONE|731.45|LAV|1800|1.0|11.0|NONE|731.45|LAV|1900|1.0|9.0|NONE|731.45|LAV|2000|1.0|10.0|NONE|731.45|LAV|2100|1.0|10.0|NONE|731.45|MJ|4800|1.0|8.0|NONE|731.45|MJ|5000|1.0|4.0|NONE|731.45|MJ|5100|1.0|3.0|NONE|731.45|ZA|5100|1.0|8.0|NONE|731.45|ZU|4800|1.0|7.0|NONE|731.45|ZU|4900|1.0|8.0|NONE|731.45|ALM|4800|0.0|5.0|NONE|0.0|ALM|4900|0.0|4.0|NONE|0.0|ALT|2100|0.0|1.0|NONE|0.0|COL|1900|0.0|7.0|NONE|0.0|COL|2000|0.0|7.0|NONE|0.0|COL|2100|0.0|6.0|NONE|0.0|GCA|6500|0.0|3.0|NONE|0.0|JCP|1700|0.0|12.0|NONE|0.0|JCP|2000|0.0|9.0|NONE|0.0|JCP|2100|0.0|4.0|NONE|0.0|ZA|4900|0.0|8.0|NONE|0.0|ZA|5000|0.0|8.0|NONE|0.0|ZA|5200|0.0|8.0|NONE|0.0|ZU|5000|0.0|9.0|NONE|0.0|EOQ| diff --git a/src/sql/calc2.sql b/src/sql/calc2.sql new file mode 100644 index 0000000..562c100 --- /dev/null +++ b/src/sql/calc2.sql @@ -0,0 +1,114 @@ +UPDATE trf_ppmc SET Tstamp = CURRENT_TIMESTAMP WHERE Tstamp IS NULL; +UPDATE trf_pers SET Tstamp = CURRENT_TIMESTAMP WHERE Tstamp IS NULL AND Abr IS NOT NULL; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'R197' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'ALT' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'RSP' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'JCP' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'ZU' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'GC' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'MJ' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'ZA' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'COL' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'LAV' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'ALM' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'GCA' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'GO' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'PU' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'FR' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'LG' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Avg_vehp = (SELECT ROUND(AVG(Vehp), 0) FROM trf_pers WHERE trf_pers.Abr = 'JVG' AND trf_pers.Vehp >= 0) WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'R197' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'R197' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALT' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALT' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'RSP' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'RSP' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JCP' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JCP' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZU' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZU' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GC' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GC' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'MJ' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'MJ' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZA' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZA' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'COL' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'COL' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LAV' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LAV' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALM' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALM' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GCA' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GCA' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GO' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GO' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'PU' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'PU' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JVG' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JVG' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'FR' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'FR' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LG' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LG' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'R197' ) WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ALT' ) WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'RSP' ) WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'JCP' ) WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ZU' ) WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'GC' ) WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'MJ' ) WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ZA' ) WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'COL' ) WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'LAV' ) WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ALM' ) WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'GO' ) WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'PU' ) WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'FR' ) WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'LG' ) WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'GCA' ) WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'JVG' ) WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Est_avg_ppmr = (SELECT ROUND(AVG(Avg_ppmr),2) FROM trf_streets WHERE Avg_ppmr > 0 AND Avg_ppmr IS NOT NULL); +UPDATE trf_streets SET Est_avg_ppmc = (SELECT ROUND(AVG(Avg_ppmc),2) FROM trf_streets WHERE Avg_ppmc > 0 AND Avg_ppmc IS NOT NULL); + +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'R197' ) WHERE Abr = 'R197'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ALT' ) WHERE Abr = 'ALT'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'RSP' ) WHERE Abr = 'RSP'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'JCP' ) WHERE Abr = 'JCP'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ZU' ) WHERE Abr = 'ZU'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'GC' ) WHERE Abr = 'GC'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'MJ' ) WHERE Abr = 'MJ'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ZA' ) WHERE Abr = 'ZA'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'COL' ) WHERE Abr = 'COL'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'LAV' ) WHERE Abr = 'LAV'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ALM' ) WHERE Abr = 'ALM'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'GO' ) WHERE Abr = 'PU'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'FR' ) WHERE Abr = 'LG'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'GCA' ) WHERE Abr = 'GCA'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehp), 2) FROM trf_streets WHERE ((Avg_vehp > 0 AND Avg_vehp IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'JVG' ) WHERE Abr = 'JVG'; +UPDATE trf_streets SET Value_pvehp = (SELECT ROUND(AVG(Value_pvehp), 2) FROM trf_streets WHERE Value_pvehp > 0 AND Value_pvehp IS NOT NULL) WHERE Value_pvehp = 0 OR Value_pvehp IS NULL; +UPDATE trf_streets SET Est_final_ppmc = (SELECT ROUND((Value_pvehp * Avg_vehp), 2) FROM trf_streets WHERE Avg_ppmc IS NOT NULL AND Avg_ppmc > 0 AND Samples_total > 31); +UPDATE trf_streets SET Est_final_ppmc = (SELECT ROUND((( SELECT AVG(Value_pvehp) FROM trf_streets WHERE Value_pvehp IS NOT NULL AND Value_pvehp > 0) * Avg_vehp), 2) FROM trf_streets WHERE Avg_ppmc IS NOT NULL AND Avg_ppmc > 0 AND Samples_total > 31); +UPDATE trf_streets SET Est_final_ppmc = ROUND((Value_pvehp * Avg_vehp), 2); +UPDATE trf_blocks SET Avg_vehp = ( SELECT ROUND(AVG(Vehp),0) FROM trf_pers WHERE Abr = trf_blocks.Abr AND Alt = trf_blocks.Alt AND Vehp >= 0); +UPDATE trf_blocks SET Avg_samples = ( SELECT COUNT (*) FROM trf_pers WHERE Abr = trf_blocks.Abr AND Alt = trf_blocks.Alt AND Vehp >= 0); +UPDATE trf_blocks SET Stat_relevant = 'NONE' WHERE Avg_samples < 36; +UPDATE trf_blocks SET Stat_relevant = 'LOW' WHERE Avg_samples >= 36; +UPDATE trf_blocks SET Stat_relevant = 'MEDIUM' WHERE Avg_samples >= 72; +UPDATE trf_blocks SET Stat_relevant = 'HIGH' WHERE Avg_samples >= 108; +UPDATE trf_blocks SET Est_final_ppmc = ( ( SELECT MAX( Est_avg_ppmc ) FROM trf_streets) / ( SELECT AVG(Avg_vehp) FROM trf_streets WHERE Samples_total > 0) ); +UPDATE trf_blocks SET Est_final_ppmc = (ROUND( ( Est_final_ppmc * Avg_vehp ), 2 )); +UPDATE trf_blocks SET m1s = 0.00; +UPDATE trf_blocks SET p1s = 0.00; +UPDATE trf_blocks SET m2s = 0.00; +UPDATE trf_blocks SET p2s = 0.00; +UPDATE trf_blocks SET m3s = 0.00; +UPDATE trf_blocks SET p3s = 0.00; +UPDATE trf_blocks SET m1s = ( SELECT ROUND ( ( Est_final_ppmc - ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 1 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET p1s = ( SELECT ROUND ( ( Est_final_ppmc + ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 1 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET m2s = ( SELECT ROUND ( ( Est_final_ppmc - ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 2 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET p2s = ( SELECT ROUND ( ( Est_final_ppmc + ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 2 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET m3s = ( SELECT ROUND ( ( Est_final_ppmc - ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 3 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET p3s = ( SELECT ROUND ( ( Est_final_ppmc + ( ( sqrt( SELECT Est_final_ppmc FROM trf_blocks ) ) * 3 ) ), 2 ) FROM trf_blocks ); +SELECT * FROM trf_streets WHERE Samples_total > 0 ORDER BY Avg_pvehp DESC; +SELECT * FROM trf_blocks ORDER BY Est_final_ppmc DESC; diff --git a/src/sql/calc3.sql b/src/sql/calc3.sql new file mode 100644 index 0000000..5d58175 --- /dev/null +++ b/src/sql/calc3.sql @@ -0,0 +1,114 @@ +UPDATE trf_ppmc SET Tstamp = CURRENT_TIMESTAMP WHERE Tstamp IS NULL; +UPDATE trf_pers SET Tstamp = CURRENT_TIMESTAMP WHERE Tstamp IS NULL AND Abr IS NOT NULL; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'R197' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'ALT' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'RSP' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'JCP' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'ZU' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'GC' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'MJ' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'ZA' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'COL' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'LAV' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'ALM' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'GCA' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'GO' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'PU' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'FR' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'LG' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Avg_vehr = (SELECT ROUND(AVG(Vehr), 0) FROM trf_pers WHERE trf_pers.Abr = 'JVG' AND trf_pers.Vehr >= 0) WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'R197' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'R197' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALT' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALT' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'RSP' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'RSP' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JCP' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JCP' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZU' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZU' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GC' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GC' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'MJ' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'MJ' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZA' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ZA' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'COL' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'COL' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LAV' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LAV' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALM' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'ALM' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GCA' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GCA' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GO' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'GO' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'PU' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'PU' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JVG' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'JVG' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'FR' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'FR' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Avg_ppmc = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LG' AND trf_ppmc.Zone = 'C') WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Avg_ppmr = (SELECT ROUND (AVG(Value),2) FROM trf_ppmc WHERE trf_ppmc.Abr = 'LG' AND trf_ppmc.Zone = 'R') WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'R197' ) WHERE trf_streets.Abr = 'R197'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ALT' ) WHERE trf_streets.Abr = 'ALT'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'RSP' ) WHERE trf_streets.Abr = 'RSP'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'JCP' ) WHERE trf_streets.Abr = 'JCP'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ZU' ) WHERE trf_streets.Abr = 'ZU'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'GC' ) WHERE trf_streets.Abr = 'GC'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'MJ' ) WHERE trf_streets.Abr = 'MJ'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ZA' ) WHERE trf_streets.Abr = 'ZA'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'COL' ) WHERE trf_streets.Abr = 'COL'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'LAV' ) WHERE trf_streets.Abr = 'LAV'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'ALM' ) WHERE trf_streets.Abr = 'ALM'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'GO' ) WHERE trf_streets.Abr = 'GO'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'PU' ) WHERE trf_streets.Abr = 'PU'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'FR' ) WHERE trf_streets.Abr = 'FR'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'LG' ) WHERE trf_streets.Abr = 'LG'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'GCA' ) WHERE trf_streets.Abr = 'GCA'; +UPDATE trf_streets SET Samples_total = ( SELECT COUNT (*) FROM trf_pers WHERE trf_pers.Abr = 'JVG' ) WHERE trf_streets.Abr = 'JVG'; +UPDATE trf_streets SET Est_avg_ppmr = (SELECT ROUND(AVG(Avg_ppmr),2) FROM trf_streets WHERE Avg_ppmr > 0 AND Avg_ppmr IS NOT NULL); +UPDATE trf_streets SET Est_avg_ppmc = (SELECT ROUND(AVG(Avg_ppmc),2) FROM trf_streets WHERE Avg_ppmc > 0 AND Avg_ppmc IS NOT NULL); + +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'R197' ) WHERE Abr = 'R197'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ALT' ) WHERE Abr = 'ALT'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'RSP' ) WHERE Abr = 'RSP'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'JCP' ) WHERE Abr = 'JCP'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ZU' ) WHERE Abr = 'ZU'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'GC' ) WHERE Abr = 'GC'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'MJ' ) WHERE Abr = 'MJ'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ZA' ) WHERE Abr = 'ZA'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'COL' ) WHERE Abr = 'COL'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'LAV' ) WHERE Abr = 'LAV'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'ALM' ) WHERE Abr = 'ALM'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'GO' ) WHERE Abr = 'PU'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'FR' ) WHERE Abr = 'LG'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'GCA' ) WHERE Abr = 'GCA'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Avg_ppmc / Avg_vehr), 2) FROM trf_streets WHERE ((Avg_vehr > 0 AND Avg_vehr IS NOT NULL) AND (Avg_ppmc > 0 and Avg_ppmc IS NOT NULL)) AND Abr = 'JVG' ) WHERE Abr = 'JVG'; +UPDATE trf_streets SET Value_pvehr = (SELECT ROUND(AVG(Value_pvehr), 2) FROM trf_streets WHERE Value_pvehr > 0 AND Value_pvehr IS NOT NULL) WHERE Value_pvehr = 0 OR Value_pvehr IS NULL; +UPDATE trf_streets SET Est_final_ppmc = (SELECT ROUND((Value_pvehr * Avg_vehr), 2) FROM trf_streets WHERE Avg_ppmc IS NOT NULL AND Avg_ppmc > 0 AND Samples_total > 31); +UPDATE trf_streets SET Est_final_ppmc = (SELECT ROUND((( SELECT AVG(Value_pvehr) FROM trf_streets WHERE Value_pvehr IS NOT NULL AND Value_pvehr > 0) * Avg_vehr), 2) FROM trf_streets WHERE Avg_ppmc IS NOT NULL AND Avg_ppmc > 0 AND Samples_total > 31); +UPDATE trf_streets SET Est_final_ppmc = ROUND((Value_pvehr * Avg_vehr), 2); +UPDATE trf_blocks SET Avg_vehr = ( SELECT ROUND(AVG(Vehr ),0) FROM trf_pers WHERE Abr = trf_blocks.Abr AND Alt = trf_blocks.Alt AND Vehr >= 0); +UPDATE trf_blocks SET Avg_samples = ( SELECT COUNT (*) FROM trf_pers WHERE Abr = trf_blocks.Abr AND Alt = trf_blocks.Alt AND Vehr >= 0); +UPDATE trf_blocks SET Stat_relevant = 'NONE' WHERE Avg_samples < 36; +UPDATE trf_blocks SET Stat_relevant = 'LOW' WHERE Avg_samples >= 36; +UPDATE trf_blocks SET Stat_relevant = 'MEDIUM' WHERE Avg_samples >= 72; +UPDATE trf_blocks SET Stat_relevant = 'HIGH' WHERE Avg_samples >= 108; +UPDATE trf_blocks SET Est_final_ppmc = ( ( SELECT MAX( Est_avg_ppmc ) FROM trf_streets) / ( SELECT AVG(Avg_vehr) FROM trf_streets WHERE Samples_total > 0) ); +UPDATE trf_blocks SET Est_final_ppmc = (ROUND( ( Est_final_ppmc * Avg_vehr ), 2 )); +UPDATE trf_blocks SET m1s = 0.00; +UPDATE trf_blocks SET p1s = 0.00; +UPDATE trf_blocks SET m2s = 0.00; +UPDATE trf_blocks SET p2s = 0.00; +UPDATE trf_blocks SET m3s = 0.00; +UPDATE trf_blocks SET p3s = 0.00; +UPDATE trf_blocks SET m1s = ( SELECT ROUND ( ( Est_final_ppmc - ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 1 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET p1s = ( SELECT ROUND ( ( Est_final_ppmc + ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 1 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET m2s = ( SELECT ROUND ( ( Est_final_ppmc - ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 2 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET p2s = ( SELECT ROUND ( ( Est_final_ppmc + ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 2 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET m3s = ( SELECT ROUND ( ( Est_final_ppmc - ( ( stdev( SELECT Est_final_ppmc FROM trf_blocks ) ) * 3 ) ), 2 ) FROM trf_blocks ); +UPDATE trf_blocks SET p3s = ( SELECT ROUND ( ( Est_final_ppmc + ( ( sqrt( SELECT Est_final_ppmc FROM trf_blocks ) ) * 3 ) ), 2 ) FROM trf_blocks ); +SELECT * FROM trf_streets WHERE Samples_total > 0 ORDER BY Avg_pvehr DESC; +SELECT * FROM trf_blocks ORDER BY Est_final_ppmc DESC; diff --git a/src/sql/prep.sql b/src/sql/prep.sql index 4e403ae..71f321e 100644 --- a/src/sql/prep.sql +++ b/src/sql/prep.sql @@ -1,8 +1,8 @@ UPDATE trf_pers SET Status = 'enabled' WHERE Status IS NULL; UPDATE trf_pers SET Context = 'center' WHERE Context IS NULL; -UPDATE trf_pers SET Hr = 16 WHERE Hr IS NULL; -UPDATE trf_pers SET Dayn = 17 WHERE Dayn IS NULL; -UPDATE trf_pers SET Dayw = 'Fri' WHERE Dayw IS NULL; +UPDATE trf_pers SET Hr = 11 WHERE Hr IS NULL; +UPDATE trf_pers SET Dayn = 19 WHERE Dayn IS NULL; +UPDATE trf_pers SET Dayw = 'Sun' WHERE Dayw IS NULL; UPDATE trf_pers SET Monthn = 1 WHERE Monthn IS NULL; UPDATE trf_pers SET Year = 2020 WHERE Year IS NULL; diff --git a/src/sql/rep2.sql b/src/sql/rep2.sql new file mode 100644 index 0000000..0a37865 --- /dev/null +++ b/src/sql/rep2.sql @@ -0,0 +1 @@ +SELECT Abr, Alt, Avg_vehp, Avg_samples, Stat_relevant, Est_final_ppmc FROM trf_blocks ORDER BY Est_final_ppmc DESC; diff --git a/src/sql/rep3.sql b/src/sql/rep3.sql new file mode 100644 index 0000000..8cf4138 --- /dev/null +++ b/src/sql/rep3.sql @@ -0,0 +1 @@ +SELECT Abr, Alt, Avg_vehr, Avg_samples, Stat_relevant, Est_final_ppmc FROM trf_blocks ORDER BY Est_final_ppmc DESC;