Skip to content

Instantly share code, notes, and snippets.

@Meussdorffer
Created August 12, 2022 16:15
Show Gist options
  • Save Meussdorffer/f6b91c8e21d1fdca7446e484cbe587a2 to your computer and use it in GitHub Desktop.
Save Meussdorffer/f6b91c8e21d1fdca7446e484cbe587a2 to your computer and use it in GitHub Desktop.
SELECT
'letter' AS resource,
CASE
WHEN size = 'A5' THEN '5.8x8.3'
ELSE size
END AS size,
COUNT(*) AS page_count
FROM lob.letters l
WHERE
l.send_date >= date_trunc('month', current_date - interval '1 month')
AND l.send_date < date_trunc('month', current_date)
GROUP BY 1, 2
UNION ...
-- similar queries for other types of mailpieces below
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment