Report not found

There was a problem finding this report.

Report

Trips - Python Window

Trips - SQL Window

SQL/Python Hybrid - Window Functions
January 23, 2018 · Refreshed 2 months ago

Collaborators

Run History
select count(1) as trips, date_trunc('day',start_date) as date from modeanalytics.sf_bike_share_trip group by 2
select count(1) as trips, date_trunc('day',start_date) as date from modeanalytics.sf_bike_share_trip group by 2
with input as ( select count(1) as trips, date_trunc('day',start_date) as date from modeanalytics.sf_bike_share_trip group by 2 ) select trips, avg(trips) over (order by date rows between 13 preceding and current row) as mvg_avg, -- Window function to calculate 14-day moving average of ride share trips sum(trips) over (order by date rows unbounded preceding) as running_total_trips, -- Window function to calculate the running total number of ride share trips lag(trips,7) over (order by date) as num_trips_previous_day, -- Window function to grab the number of trips on the previous day trips - lag(trips,7) over (order by date) as wow_difference, (trips - lag(trips,7) over (order by date))/lag(trips,7) over (order by date)::decimal(18,2) as wow_percent_change, -- Window function to calculate the week-over-week percent increase in trips date from input order by date
with input as ( select count(1) as trips, date_trunc('day',start_date) as date from modeanalytics.sf_bike_share_trip group by 2 ) select trips, avg(trips) over (order by date rows between 13 preceding and current row) as mvg_avg, -- Window function to calculate 14-day moving average of ride share trips sum(trips) over (order by date rows unbounded preceding) as running_total_trips, -- Window function to calculate the running total number of ride share trips lag(trips,7) over (order by date) as num_trips_previous_day, -- Window function to grab the number of trips on the previous day trips - lag(trips,7) over (order by date) as wow_difference, (trips - lag(trips,7) over (order by date))/lag(trips,7) over (order by date)::decimal(18,2) as wow_percent_change, -- Window function to calculate the week-over-week percent increase in trips date from input order by date
<div class="mode-grid container"> <div class="row" data-row-height="large"> <div class="col-md-6"> <mode-chart id="chart_da4548a04b3b" dataset="dataset" options="chart_options"></mode-chart> </div> <div class="col-md-6"></div> </div> <div class="row" data-row-height="large"> <div class="col-md-6"> <mode-python id="python_b8ca4062a6c5" options="python_options"></mode-python> </div> <div class="col-md-6"></div> </div> </div>
{{ dataSourceName(params.queryId) }}

The dataset is too large to view in browser

Export

Looks like something went wrong with your query.

{{ DS.queryRuns[params.queryId].errorMessage }}
This query was cancelled