Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 17.98 KB | None | 0 0
  1. /*
  2.  * Dedupes and aggregates the raw data to get the final output table.
  3.  */
  4. WITH
  5. /* 1. Join the raw data with the POI table. */
  6. join_poi AS (
  7.       SELECT poi.poi_type,
  8.              poi.poi_sub_type,
  9.              poi.poi_name,
  10.              poi.address,
  11.              poi.city,
  12.              LPAD(poi.zip, 5, '0') zip,
  13.              RAW.*
  14.         FROM `marketplace-0.bizsim.bizsim_output_21_30_21_30_0_true_1fc31293_1c04_4899_b919_98d113652c25` RAW
  15.   INNER JOIN `marketplace-0.bizsim.poi_output` poi
  16.           ON RAW.poi_id=poi.poi_id
  17.           AND RAW.uuid=poi.job_uuid
  18. ),
  19. /* 2. Dedup chain stores. */
  20. deduped AS (
  21.       SELECT *
  22.         FROM join_poi
  23.        WHERE poi_sub_type = 'MomAndPop'
  24.    UNION ALL
  25.       SELECT a.*
  26.         FROM join_poi a
  27.   INNER JOIN
  28.              (
  29.                  SELECT poi_name,
  30.                         destination_lane_id,
  31.                         MIN(haversine_distance_meters) haversine_distance_meters
  32.                    FROM join_poi
  33.                   WHERE poi_sub_type != 'MomAndPop'
  34.                GROUP BY poi_name,
  35.                         destination_lane_id
  36.              ) b
  37.           ON a.poi_name = b.poi_name
  38.          AND a.destination_lane_id = b.destination_lane_id
  39.          AND a.haversine_distance_meters = b.haversine_distance_meters
  40. ),
  41. /* 3. Join with population table. */
  42. join_pop AS (
  43.       SELECT deduped.*,
  44.              pop.pop_avg,
  45.              pop.size_avg
  46.         FROM deduped
  47.   INNER JOIN `marketplace-0.bizsim._gen_lanes_usa_with_pop_endpoint` pop
  48.           ON pop.pop_avg > 0 AND pop.size_avg > 0
  49.          AND deduped.destination_lane_id = pop.lane_id
  50. )
  51. /* 4. Aggregate. */
  52. SELECT
  53.          /* POI info */
  54.          poi_id,
  55.          ANY_VALUE(poi_type) poi_type,
  56.          ANY_VALUE(poi_sub_type) poi_sub_type,
  57.          ANY_VALUE(poi_name) poi_name,
  58.          ANY_VALUE(address) poi_address,
  59.          ANY_VALUE(city) poi_city,
  60.          ANY_VALUE(state) poi_state,
  61.          ANY_VALUE(zip) poi_zip,
  62.          zip_code destination_zip,
  63.  
  64.          /* Reachability statistics */
  65.          SUM(size_avg) unconstrained_sq_meters,
  66.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN size_avg ELSE 0 END) constrained_sq_meters,
  67.          SUM(pop_avg) unconstrained_pop,
  68.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END) / SUM(pop_avg) physical_reachability,
  69.  
  70.          /* The following four columns have physical_reachability as the denominator. */
  71.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 10 THEN pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) physical_reachability_10_min,
  72.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 13 THEN pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) physical_reachability_13_min,
  73.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 15 THEN pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) physical_reachability_15_min,
  74.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 20 THEN pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) physical_reachability_20_min,
  75.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 30 THEN pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) physical_reachability_30_min,
  76.          /* The following four columns have the corresponding physical_reachability_*_min column as the denominator. detour factor using time */
  77.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 10 AND
  78.             constrained_time_minutes / unconstrained_time_minutes < (CASE
  79.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  80.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  81.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  82.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  83.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  84.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  85.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  86.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 10 THEN pop_avg ELSE 0 END)) lsv_by_time_10_min,
  87.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 13 AND
  88.             constrained_time_minutes / unconstrained_time_minutes < (CASE
  89.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  90.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  91.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  92.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  93.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  94.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  95.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  96.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 13 THEN pop_avg ELSE 0 END)) lsv_by_time_13_min,
  97.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 15 AND
  98.             constrained_time_minutes / unconstrained_time_minutes < (CASE
  99.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  100.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  101.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  102.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  103.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  104.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  105.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  106.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 15 THEN pop_avg ELSE 0 END)) lsv_by_time_15_min,
  107.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 20 AND
  108.             constrained_time_minutes / unconstrained_time_minutes < (CASE
  109.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  110.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  111.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  112.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  113.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  114.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  115.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  116.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 20 THEN pop_avg ELSE 0 END)) lsv_by_time_20_min,
  117.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 30 AND
  118.             constrained_time_minutes / unconstrained_time_minutes < (CASE
  119.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  120.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  121.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  122.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  123.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  124.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  125.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  126.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 30 THEN pop_avg ELSE 0 END)) lsv_by_time_30_min,
  127.           /* The following four columns have the corresponding physical_reachability_*_min column as the denominator. detour factor using distance */
  128.           SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 10 AND
  129.             constrained_dist_total_miles / unconstrained_dist_total_miles < (CASE
  130.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  131.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  132.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  133.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  134.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  135.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  136.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  137.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 10 THEN pop_avg ELSE 0 END)) lsv_by_distance_10_min,
  138.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 13 AND
  139.             constrained_dist_total_miles / unconstrained_dist_total_miles < (CASE
  140.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  141.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  142.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  143.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  144.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  145.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  146.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  147.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 13 THEN pop_avg ELSE 0 END)) lsv_by_distance_13_min,
  148.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 15 AND
  149.             constrained_dist_total_miles / unconstrained_dist_total_miles < (CASE
  150.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  151.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  152.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  153.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  154.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  155.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  156.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  157.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 15 THEN pop_avg ELSE 0 END)) lsv_by_distance_15_min,
  158.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 20 AND
  159.             constrained_dist_total_miles / unconstrained_dist_total_miles < (CASE
  160.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  161.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  162.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  163.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  164.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  165.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  166.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  167.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 20 THEN pop_avg ELSE 0 END)) lsv_by_distance_20_min,
  168.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 30 AND
  169.             constrained_dist_total_miles / unconstrained_dist_total_miles < (CASE
  170.             WHEN poi_type = 'QSR' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  171.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'RestaurantChain' THEN 1.25
  172.             WHEN poi_type = 'FoodAggregator' AND poi_sub_type = 'MomAndPop' THEN 1.25
  173.             WHEN poi_type = 'Grocery' AND poi_sub_type = 'GroceryChain' THEN 1.5
  174.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'ConvenienceStores' THEN 1.5
  175.             WHEN poi_type = 'ConvenienceStores' AND poi_sub_type = 'Pharmacy' THEN 1.5
  176.             ELSE 1 END) THEN pop_avg ELSE 0 END),
  177.          SUM(CASE WHEN constrained_time_minutes IS NOT NULL AND constrained_time_minutes <= 30 THEN pop_avg ELSE 0 END)) lsv_by_distance_30_min,
  178.  
  179.          /* Constrained route breakdown */
  180.          SAFE_DIVIDE(SUM(constrained_dist_total_miles * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_dist_total_miles,
  181.          SAFE_DIVIDE(SUM(constrained_time_minutes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_time_minutes,
  182.  
  183.          SAFE_DIVIDE(SUM(constrained_dist_over_55_mph_miles * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_dist_over_55_mph_miles,
  184.          SAFE_DIVIDE(SUM(constrained_dist_41_to_54_mph_miles * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_dist_41_to_54_mph_miles,
  185.          SAFE_DIVIDE(SUM(constrained_dist_31_to_40_mph_miles * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_dist_31_to_40_mph_miles,
  186.          SAFE_DIVIDE(SUM(constrained_dist_0_to_30_mph_miles * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_dist_0_to_30_mph_miles,
  187.  
  188.          SAFE_DIVIDE(SUM(constrained_num_upc_over_55_mph_1_lane * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_over_55_mph_1_lane,
  189.          SAFE_DIVIDE(SUM(constrained_num_upc_41_to_54_mph_1_lane * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_41_to_54_mph_1_lane,
  190.          SAFE_DIVIDE(SUM(constrained_num_upc_31_to_40_mph_1_lane * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_31_to_40_mph_1_lane,
  191.          SAFE_DIVIDE(SUM(constrained_num_upc_0_to_30_mph_1_lane * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_0_to_30_mph_1_lane,
  192.  
  193.          SAFE_DIVIDE(SUM(constrained_num_upc_over_55_mph_2_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_over_55_mph_2_lanes,
  194.          SAFE_DIVIDE(SUM(constrained_num_upc_41_to_54_mph_2_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_41_to_54_mph_2_lanes,
  195.          SAFE_DIVIDE(SUM(constrained_num_upc_31_to_40_mph_2_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_31_to_40_mph_2_lanes,
  196.          SAFE_DIVIDE(SUM(constrained_num_upc_0_to_30_mph_2_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_0_to_30_mph_2_lanes,
  197.  
  198.          SAFE_DIVIDE(SUM(constrained_num_upc_over_55_mph_over_3_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_over_55_mph_over_3_lanes,
  199.          SAFE_DIVIDE(SUM(constrained_num_upc_41_to_54_mph_over_3_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_41_to_54_mph_over_3_lanes,
  200.          SAFE_DIVIDE(SUM(constrained_num_upc_31_to_40_mph_over_3_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_31_to_40_mph_over_3_lanes,
  201.          SAFE_DIVIDE(SUM(constrained_num_upc_0_to_30_mph_over_3_lanes * pop_avg), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_constrained_num_upc_0_to_30_mph_over_3_lanes,
  202.  
  203.          /* Unconstrained route breakdown */
  204.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN unconstrained_dist_total_miles * pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_unconstrained_dist_total_miles,
  205.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN unconstrained_time_minutes * pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_unconstrained_time_minutes,
  206.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN unconstrained_dist_over_55_mph_miles * pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_unconstrained_dist_over_55_mph_miles,
  207.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN unconstrained_dist_41_to_54_mph_miles * pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_unconstrained_dist_41_to_54_mph_miles,
  208.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN unconstrained_dist_31_to_40_mph_miles * pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_unconstrained_dist_31_to_40_mph_miles,
  209.          SAFE_DIVIDE(SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN unconstrained_dist_0_to_30_mph_miles * pop_avg ELSE 0 END), SUM(CASE WHEN constrained_time_minutes IS NOT NULL THEN pop_avg ELSE 0 END)) avg_unconstrained_dist_0_to_30_mph_miles
  210.     FROM join_pop
  211. GROUP BY poi_id, zip_code;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement