mirror of
https://github.com/maplibre/martin.git
synced 2024-12-25 16:02:55 +03:00
11 lines
380 B
SQL
11 lines
380 B
SQL
drop table if exists trips_by_hour;
|
|
create table trips_by_hour as
|
|
select
|
|
pulocationid,
|
|
count(*) as trips_count,
|
|
round(avg(total_amount)) trips_price,
|
|
round(avg(extract(epoch from (dropoff_datetime - pickup_datetime)) / 60))::INTEGER trips_duration,
|
|
date_trunc('hour', pickup_datetime) as pickup_datetime
|
|
from trips
|
|
group by pulocationid, date_trunc('hour', pickup_datetime);
|