I am taking a database course and we are required to create some SQL queries. So don't give me the answer if possible. Just let me know what is wrong with this code:
SELECT
p.pat_id,
p.pat_first_name,
p.pat_last_name,
p.pat_dob,
ph.phys_last_name,
s.service_desc,
v.visit_date
FROM Visit as v
LEFT OUTER JOIN Visit_Service as vs on vs.visit_id = v.visit_id
LEFT OUTER JOIN Patient as p on p.pat_id = v.pat_id
LEFT OUTER JOIN Service as s on s.service_cd = vs.service_cd
LEFT OUTER JOIN Physician as ph on ph.phys_id = v.phys_id
WHERE v.pat_id = '101'
GROUP BY p.pat_id
HAVING v.visit_date = MAX(v.visit_date)
Thanks so much, Dawn