Skip to content

Instantly share code, notes, and snippets.

@jeff

jeff/output.txt Secret

Created November 9, 2018 16:45
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 jeff/fccb56ea0181b24c5d096d4c9281a537 to your computer and use it in GitHub Desktop.
Save jeff/fccb56ea0181b24c5d096d4c9281a537 to your computer and use it in GitHub Desktop.
day | age
------------+----------
2008-11-09 | 10 years
(1 row)
SELECT
date_trunc('day', create_date)::DATE AS day,
age(now()::DATE, date_trunc('day', create_date)::DATE) AS age
FROM asset.call_number
WHERE owning_lib IN (
SELECT id FROM actor.org_unit_descendants(
(SELECT id FROM actor.org_unit WHERE shortname = 'TADL')
)
)
GROUP BY day, age
ORDER BY count(*) DESC
LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment