Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ashugupt
Created June 20, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashugupt/696247852714eb730961d167511214af to your computer and use it in GitHub Desktop.
Save ashugupt/696247852714eb730961d167511214af to your computer and use it in GitHub Desktop.
SELECT
b.cluster_name,
SUM(a.total_shipments) AS total_shipments
FROM (
SELECT
booking_cluster_id,
1 AS total_shipments
FROM shipment
WHERE 1=1
AND timestamp BETWEEN '{{ last_sunday }}'
AND '{{ this_saturday }}'
) shipment
JOIN (
SELECT
cluster_id,
cluster_name
FROM locations
WHERE 1=1
AND timestamp BETWEEN '{{ latest_ds }}'
) b
ON (a.booking_cluster_id = b.cluster_id)
GROUP BY b.cluster_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment