I currently have 3 tables (diagnosis, encounters, and encounter diagnosis). 1 is the link to see the table outputs
I currently wrote a code that gives me everything I want, but I am looking for the first time a diagnosis occurred. code and output
Here is the code. Can anyone tell me how to get rid of duplicates?
SELECT a.code, a.title, c.start_dts
FROM edw_emr_ods.diagnoses AS a
JOIN edw_emr_ods.encounter_diagnoses as b on a.diagnosis_id=b.diagnosis_id
JOIN edw_emr_ods.encounters as c on b.encounter_id=c.encounter_id
ORDER BY a.title ASC;
I tried grouping, but I get an error that a.code
is not listed in the GROUP.
Sorry I'm new to SQL and trying to pass a test and this is a practice problem