Created
December 6, 2019 04:21
-
-
Save shivrajbadu/311afd7ac238ec45ed364422403cfb68 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
| def self.qry | |
| res = Patient.find_by_sql(%{ | |
| select * 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, year, month, day | |
| having count(id) = 1 | |
| }) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment