Last active
October 29, 2015 15:39
-
-
Save naranjja/a761a9b1b8aece02aa1e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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