Created
December 6, 2019 12:04
-
-
Save userrails/db529388ba1e2d4da9e145acbea3aab4 to your computer and use it in GitHub Desktop.
This file contains 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
DROP TEMPORARY TABLE IF EXISTS patient_visits; | |
CREATE TEMPORARY TABLE patient_visits LIKE patients; | |
INSERT INTO patient_visits | |
SELECT * | |
FROM patients | |
WHERE id | |
IN ( | |
SELECT patient_id | |
FROM patient_histories | |
GROUP BY patient_id | |
HAVING COUNT(patient_id) = 1 | |
); | |
select * from patient_visits join patient_histories | |
on patient_visits.id = patient_histories.patient_id | |
where patient_histories.year="2076" | |
and patient_histories.month="8" | |
and patient_histories.day="19" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment