Skip to content

Instantly share code, notes, and snippets.

@drio
Created June 30, 2021 17:15
Show Gist options
  • Save drio/c10350f3d76a7d65714870d883939326 to your computer and use it in GitHub Desktop.
Save drio/c10350f3d76a7d65714870d883939326 to your computer and use it in GitHub Desktop.
SELECT
NVL (MIN(days_since_last_positive), 0) AS days_since_last_positive
FROM (
SELECT
order_id,
ROUND(trunc(sysdate) - to_date(specimen_received_datetime, 'YYYY-MM-DD"T"HH24:MI:SS'), 2) AS days_since_last_positive
FROM
covid.results
WHERE
tufts_person_id = '1295695'
AND result_value = 'POSITIVE'
ORDER BY
specimen_received_datetime DESC)
WHERE
rownum < 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment