Skip to content

Instantly share code, notes, and snippets.

@patdevinwilson
Created March 8, 2017 22:02
Show Gist options
  • Save patdevinwilson/d2fbf6849359f426b8d5d823f311cd3b to your computer and use it in GitHub Desktop.
Save patdevinwilson/d2fbf6849359f426b8d5d823f311cd3b to your computer and use it in GitHub Desktop.
SELECT
COUNT(1) AS video_count,
ROUND((AVG(v.duration)/60)::numeric,2) AS average_duration_minutes,
ROUND((MIN(v.duration)/60)::numeric,2) AS min_duration_minutes,
ROUND((MAX(v.duration)/60)::numeric,2) AS max_duration_minutes,
ROUND(SUM(v.duration)::numeric,2) AS total_duration_seconds,
ROUND((SUM(v.duration)/60)::numeric,2) AS total_duration_minutes,
ROUND(((SUM(v.duration)/60)/60)::numeric,2) AS total_duration_hours,
ROUND(AVG(ST_Length(v.geometry::geography))::numeric,2) AS average_track_length_meters,
ROUND(MIN(ST_Length(v.geometry::geography))::numeric,2) AS min_track_length_meters,
ROUND(MAX(ST_Length(v.geometry::geography))::numeric,2) AS max_track_length_meters,
ROUND(SUM(ST_Length(v.geometry::geography))::numeric,2) AS total_track_length_meters,
ROUND(SUM(ST_Length(v.geometry::geography)/1000)::numeric,2) AS total_track_length_kilometers
FROM videos v;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment