Skip to content

Instantly share code, notes, and snippets.

@naranjja
Last active October 29, 2015 15:39
Show Gist options
  • Save naranjja/a761a9b1b8aece02aa1e to your computer and use it in GitHub Desktop.
Save naranjja/a761a9b1b8aece02aa1e to your computer and use it in GitHub Desktop.
SET DateStyle TO DMY;
SELECT
historia,
COUNT(DISTINCT(historia)) AS veces,
SUBSTRING(edad,1,2) AS edad,
DATE_PART('day', fecing::TIMESTAMP - fecisn::TIMESTAMP) AS estancia,
sexo,
SUBSTRING(procprov, '- *([A-Z, ]{1,15})') AS departamento
FROM hospital
WHERE historia <> '0'
GROUP BY historia, edad, fecing, fecisn, sexo, procprov
ORDER BY historia ASC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment