Last active
December 6, 2019 05:22
-
-
Save shivrajbadu/2f9d2dc2a1799f36f53467376528f33d to your computer and use it in GitHub Desktop.
ignore duplicates
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
| res = Patient.find_by_sql(%{ | |
| select id from ( | |
| select | |
| patients.id as id, | |
| patient_histories.year as year, | |
| patient_histories.month as month, | |
| patient_histories.day as day | |
| from patients | |
| join patient_histories | |
| on patients.id=patient_histories.patient_id | |
| where patients.gender="female" | |
| and patient_histories.year = '2076' | |
| group by | |
| patients.id, | |
| patient_histories.year, | |
| patient_histories.month, | |
| patient_histories.day | |
| having count(patient_histories.patient_id) = 1 | |
| )t group by id | |
| having (count(*) = 1) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment