Skip to content

Instantly share code, notes, and snippets.

@dylanirlbeck
Last active August 18, 2020 16:07
Show Gist options
  • Save dylanirlbeck/e2cf211ebb5c3e50fa1e7a5d49f52e31 to your computer and use it in GitHub Desktop.
Save dylanirlbeck/e2cf211ebb5c3e50fa1e7a5d49f52e31 to your computer and use it in GitHub Desktop.
SELECT ((COALESCE(outbound_deliveries.departure_time, CURRENT_TIMESTAMP) - inbound_deliveries.arrival_time) / 3600) AS turnaround_time
FROM inbound_deliveries
INNER JOIN outbound_deliveries ON outbound_deliveries.inbound_delivery_id = inbound_deliveries.id
GROUP BY inbound_deliveries.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment